Skip to content

Commit

Permalink
Simple node app boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
GambuzX committed Feb 28, 2021
1 parent 9c80cef commit f3c1307
Show file tree
Hide file tree
Showing 4 changed files with 1,004 additions and 0 deletions.
36 changes: 36 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const express = require('express');
const cors = require('cors');
const dotenv = require('dotenv');
const helmet = require('helmet');
const routes = require('./routes/index');
const httpStatus = require('http-status');

const app = express();

// load env variables
dotenv.config();

// set security HTTP headers
app.use(helmet());

// parse json request body
app.use(express.json());

// parse urlencoded request body
app.use(express.urlencoded({ extended: true }));

// enable cors
app.use(cors());
app.options('*', cors());

// v1 api routes
app.use('/', routes);

// send back a 404 error for any unknown api request
app.get("*", (req, res) => {
res.send("404 - Not found");
});

app.listen(process.env.PORT, () => {
console.log("Server has started");
})
Loading

0 comments on commit f3c1307

Please sign in to comment.