File tree Expand file tree Collapse file tree 5 files changed +842
-0
lines changed Expand file tree Collapse file tree 5 files changed +842
-0
lines changed Original file line number Diff line number Diff line change
1
+ .DS_Store
2
+ node_modules
3
+ /dist
4
+
5
+
6
+ # local env files
7
+ .env.local
8
+ .env. * .local
9
+ .env
10
+
11
+ # Log files
12
+ npm-debug.log *
13
+ yarn-debug.log *
14
+ yarn-error.log *
15
+ pnpm-debug.log *
16
+
17
+ # Editor directories and files
18
+ .idea
19
+ .vscode
20
+ * .suo
21
+ * .ntvs *
22
+ * .njsproj
23
+ * .sln
24
+ * .sw ?
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " server" ,
3
+ "version" : " 1.0.0" ,
4
+ "main" : " server.js" ,
5
+ "scripts" : {
6
+ "test" : " echo \" Error: no test specified\" && exit 1" ,
7
+ "start" : " NODE_TLS_REJECT_UNAUTHORIZED=0 node server.js"
8
+ },
9
+ "author" : " Aditya Tandon" ,
10
+ "license" : " ISC" ,
11
+ "dependencies" : {
12
+ "cors" : " ^2.8.5" ,
13
+ "dotenv" : " ^16.3.2" ,
14
+ "express" : " ^4.18.2" ,
15
+ "request" : " ^2.88.2"
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ const express = require ( "express" ) ;
2
+ const router = express . Router ( ) ;
3
+
4
+ router . get ( "/" , ( req , res ) => {
5
+ res . send ( "Server is up and running!" ) . status ( 200 ) ;
6
+ } ) ;
7
+
8
+ module . exports = router ;
Original file line number Diff line number Diff line change
1
+ const express = require ( "express" ) ;
2
+ const request = require ( "request" ) ;
3
+ const router = require ( "./router" ) ;
4
+ const cors = require ( 'cors' ) ;
5
+ require ( 'dotenv' ) . config ( )
6
+
7
+ const app = express ( ) ;
8
+ app . use ( cors ( ) ) ;
9
+ app . use ( router ) ;
10
+ const port = process . env . PORT || 3000 ;
11
+ app . get ( '/authenticate' , ( req , res ) => {
12
+ const payload = {
13
+ clientId : process . env . CLIENT_ID ,
14
+ clientSecret : process . env . CLIENT_SECRET
15
+ } ;
16
+ request (
17
+ {
18
+ url : "https://api.jdoodle.com/v1/auth-token" ,
19
+ method : "POST" ,
20
+ json : payload
21
+ } ,
22
+ ( error , response , body ) => {
23
+ console . log ( "error:" , error ) ;
24
+ console . log ( "statusCode:" , response && response . statusCode ) ;
25
+ console . log ( "body:" , body ) ;
26
+ res . json ( body ) ;
27
+ }
28
+ ) ;
29
+ } ) ;
30
+
31
+ app . listen ( port , ( ) => {
32
+ console . log ( `Server listening at http://localhost:${ port } ` ) ;
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments