Initial commit
This commit is contained in:
23
backend/.gitignore
vendored
Normal file
23
backend/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
19
backend/app.js
Normal file
19
backend/app.js
Normal file
@ -0,0 +1,19 @@
|
||||
/* Modules */
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const morgan = require('morgan');
|
||||
|
||||
/* Files Imports & Variables */
|
||||
const { PORT } = require('./assets/config/config');
|
||||
const app = express();
|
||||
|
||||
/* Middlewares */
|
||||
app.use(cors());
|
||||
app.use(morgan('dev'));
|
||||
app.use(express.json());
|
||||
|
||||
/* Routes */
|
||||
app.get('/', (_req, res) => res.send('Hello world!'));
|
||||
|
||||
/* Server */
|
||||
app.listen(PORT, () => console.log('\x1b[36m%s\x1b[0m', `Started on port ${PORT}.`));
|
3
backend/assets/config/config.js
Normal file
3
backend/assets/config/config.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
PORT: process.env.PORT || 8080
|
||||
};
|
11
backend/assets/utils/sendResponse.js
Normal file
11
backend/assets/utils/sendResponse.js
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @description Envoie la réponse au client
|
||||
* @param {Response} res Objet réponse d'une réponse http/express
|
||||
* @param {Object} object { httpStatus, customProperties{Object}, result }
|
||||
* @param {Boolean} isSuccess
|
||||
*/
|
||||
function sendResponse (res, object, isSuccess = false) {
|
||||
res.status(object.httpStatus || 200).send({ isSuccess, ...object.customProperties, result: object.result });
|
||||
}
|
||||
|
||||
module.exports = sendResponse;
|
1260
backend/package-lock.json
generated
Normal file
1260
backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
backend/package.json
Normal file
20
backend/package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"version": "1.0.0",
|
||||
"description": "Backend REST API for FunctionProject",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"start": "nodemon app.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Divlo",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"morgan": "^1.9.1",
|
||||
"nodemon": "^2.0.2"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user