Package, Server, Routes
Adding the base of the server program
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
.env
|
||||
1519
package-lock.json
generated
Normal file
1519
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
28
package.json
Normal file
28
package.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "snacks-analytics-backend",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@git.labeli.org:2223/AlexLoup/Snacks-Analitycs-backend.git"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "",
|
||||
"type": "commonjs",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"server": "nodemon ./src/server.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^17.4.2",
|
||||
"express": "^5.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.6",
|
||||
"@types/node": "^25.9.3",
|
||||
"nodemon": "^3.1.14",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^6.0.3"
|
||||
}
|
||||
}
|
||||
18
src/routes/status.routes.ts
Normal file
18
src/routes/status.routes.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import {Router} from "express";
|
||||
|
||||
// ----------------------------------------
|
||||
// Router config
|
||||
// ----------------------------------------
|
||||
const router = Router();
|
||||
|
||||
// ----------------------------------------
|
||||
// Routes
|
||||
// ----------------------------------------
|
||||
router.get("/", (req, res) => {
|
||||
res.json("Server Alive !")
|
||||
})
|
||||
|
||||
// ----------------------------------------
|
||||
// Export router
|
||||
// ----------------------------------------
|
||||
module.exports = router;
|
||||
23
src/server.ts
Normal file
23
src/server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import express from "express";
|
||||
|
||||
// ----------------------------------------
|
||||
// Backend configuration
|
||||
// ----------------------------------------
|
||||
const PORT = 5000;
|
||||
const app = express();
|
||||
|
||||
// ----------------------------------------
|
||||
// Middleware configuration
|
||||
// ----------------------------------------
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded( {extended: false }));
|
||||
|
||||
// ----------------------------------------
|
||||
// Routes import
|
||||
// ----------------------------------------
|
||||
app.use("/status", require("./routes/status.routes"));
|
||||
|
||||
// ----------------------------------------
|
||||
// Starting Server
|
||||
// ----------------------------------------
|
||||
app.listen(PORT, () => console.log("Server started at port : " + PORT));
|
||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"module": "commonjs",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user