-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simple node server to serve group maker
- Loading branch information
1 parent
7027ef6
commit ed8b8a4
Showing
17 changed files
with
1,774 additions
and
43 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }`) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.