Skip to content

Commit

Permalink
simple node server to serve group maker
Browse files Browse the repository at this point in the history
  • Loading branch information
kapil1garg committed Apr 8, 2022
1 parent 7027ef6 commit ed8b8a4
Show file tree
Hide file tree
Showing 17 changed files with 1,774 additions and 43 deletions.
529 changes: 486 additions & 43 deletions .gitignore

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';

/*
Get environment variables.
*/
const PORT = process.env.PORT || 3000;
const NODE_ENV = process.env.NODE_ENV || "development";

/*
Setup application.
*/
const app = express();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// setup routes
app.use(express.urlencoded({extended: true}));
app.use(express.json()) // To parse the incoming requests with JSON payloads
app.use("/", express.static(path.join(__dirname, 'public')));


// catch any undefined routes
app.all('*', (request, response) => {
console.log('Returning a 404 from the catch-all route');
return response.sendStatus(404);
});

// start application
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});

app.use((req, res) => {
res.send('Welcome to Express');
});

app.listen(PORT, () => {
console.log(`Server running on port ${ PORT }`)
});
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "dtr-group-maker",
"version": "1.0.0",
"description": "A tool for creating 2 groups for Pair Research and LIP during Studio sessions.",
"main": "index.js",
"repository": "[email protected]:NUDelta/dtr-group-maker.git",
"author": "Kapil Garg <[email protected]>",
"license": "MIT",
"scripts": {
"start": "node index.js",
"start-watch": "nodemon -r dotenv/config index.js",
"dev": "concurrently \"yarn run start-watch\"",
"lines": "cloc --exclude-dir=node_modules,.idea --exclude-ext=json ."
},
"engines" : {
"node" : "^16.x"
},
"type": "module",
"dependencies": {
"dotenv": "^16.0.0",
"express": "^4.17.3"
},
"devDependencies": {
"cloc": "^2.9.0",
"concurrently": "^7.1.0",
"nodemon": "^2.0.15"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ed8b8a4

Please sign in to comment.