File tree 4 files changed +25
-6
lines changed
4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const bodyParser = require("body-parser");
7
7
8
8
const app = express ( ) ;
9
9
10
- const routes = require ( "./queries/binary " ) ;
10
+ const routes = require ( "./routes.js " ) ;
11
11
12
12
app . use ( bodyParser . json ( ) ) ;
13
13
require ( "env2" ) ( "./config.env" ) ;
Original file line number Diff line number Diff line change 1
1
const mongoose = require ( "mongoose" ) ;
2
- const router = require ( "express" ) . Router ( ) ;
3
2
4
3
mongoose . connect ( process . env . DATABASE_URL ) ;
5
4
const { connection } = mongoose ;
6
- router . post ( "/trial_form" , ( req , res ) => {
5
+ exports . post = ( req , res ) => {
7
6
console . log ( "bodyyyyyyyy: " , req . body ) ;
8
7
req . body . timestamp = new Date ( ) ;
9
8
connection . collection ( "trialsData" ) . insert ( req . body ) ;
10
9
res . send ( "hello" ) ;
11
- } ) ;
12
-
13
- module . exports = router ;
10
+ } ;
Original file line number Diff line number Diff line change
1
+ const mongoose = require ( "mongoose" ) ;
2
+
3
+ mongoose . connect ( process . env . DATABASE_URL ) ;
4
+ const { connection } = mongoose ;
5
+ exports . get = ( req , res ) => {
6
+ console . log ( req . params . trialId ) ;
7
+ console . log ( "hello" ) ;
8
+ connection
9
+ . collection ( "trialsData" )
10
+ . findOne ( { trialId : `${ req . params . trialId } ` } , ( err , obj ) => {
11
+ res . send ( obj . choices ) ;
12
+ } ) ;
13
+ } ;
Original file line number Diff line number Diff line change
1
+ const router = require ( "express" ) . Router ( ) ;
2
+
3
+ const binary = require ( "./queries/binary" ) ;
4
+ const get_choices = require ( "./queries/get_choices" ) ;
5
+
6
+ router . post ( "/trial_form" , binary . post ) ;
7
+ router . get ( "/choices/:trialId" , get_choices . get ) ;
8
+
9
+ module . exports = router ;
You can’t perform that action at this time.
0 commit comments