Setup server with basic configuration
This commit is contained in:
parent
79205eb95e
commit
effa3ef442
11
api/server.js
Normal file
11
api/server.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const helmet = require('helmet');
|
||||||
|
const cors = require('cors');
|
||||||
|
|
||||||
|
const server = express();
|
||||||
|
|
||||||
|
server.use(helmet());
|
||||||
|
server.use(express.json());
|
||||||
|
server.use(cors());
|
||||||
|
|
||||||
|
module.exports = server;
|
14
index.js
Normal file
14
index.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
require("dotenv").config();
|
||||||
|
const server = require("./api/server");
|
||||||
|
|
||||||
|
server.get("/", (req, res) => {
|
||||||
|
res.json({
|
||||||
|
message: `API server for Sleep Tracker running. :)`
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const PORT = process.env.PORT;
|
||||||
|
|
||||||
|
server.listen(PORT, () => {
|
||||||
|
console.log(`Listening on port ${PORT}...`);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user