⛔ Removed redundant server code
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
# Server side boilerplate with MongoDB as database, Express framework with Typescript
|
||||
|
||||
## Introduction
|
||||
|
||||
In the Server side of boilerplate, MongoDB and Express framework with Typescript has been utilized to reach a well structured and fully separated concerns source code.
|
||||
the source code has been separated into multiple layers and every layer fully explaind with lots of details in their own README files.
|
||||
|
||||
|
||||
### Nodemon
|
||||
|
||||
Nodemon is a utility monitors for any changes in the server-side source code, and automatically restarts the server. Nodemon is just for development purposes only.
|
||||
**nodemon.json** file is used to hold the configurations for Nodemon.
|
||||
|
||||
### Express
|
||||
|
||||
Express is a web application framework for Node.js. It is used to build our backend API's.
|
||||
|
||||
**src/server/index.ts** is the entry point to the server application which starts a server and listens on port 8085 for connections. The app responds with `{username: <username>}` for requests to the URL (/api/test). It is also configured to serve the static files from **dist** directory.
|
||||
@@ -1,27 +0,0 @@
|
||||
import express, { Router, Express } from "express";
|
||||
import bodyParser from "body-parser";
|
||||
import router from "./route";
|
||||
|
||||
// call express
|
||||
const app: Express = express(); // define our app using express
|
||||
|
||||
const port: number = Number(process.env.PORT) || 8050; // set our port
|
||||
|
||||
// Configure app to respond with these headers for CORS purposes
|
||||
app.use(function (req, res, next) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header(
|
||||
"Access-Control-Allow-Headers",
|
||||
"Origin, X-Requested-With, Content-Type, Accept",
|
||||
);
|
||||
next();
|
||||
});
|
||||
|
||||
// configure app to use bodyParser for
|
||||
// Getting data from body of requests
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
// REGISTER ROUTES
|
||||
// all of the routes will be prefixed with /api
|
||||
const routes: Router[] = Object.values(router);
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface IPathRoute {
|
||||
methods: string[];
|
||||
}
|
||||
|
||||
export interface Ipath {
|
||||
[route: string]: IPathRoute;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
## Read me for routes
|
||||
@@ -1,3 +0,0 @@
|
||||
import opds from "./routes/dummy.routes";
|
||||
|
||||
export default { opds };
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Ipath, IPathRoute } from "../interfaces/path.interface";
|
||||
|
||||
function path(url: string): IPathRoute {
|
||||
const allRoutes: Ipath = {
|
||||
"/extra": {
|
||||
methods: ["POST", "GET", "PUT"],
|
||||
},
|
||||
};
|
||||
return allRoutes[url];
|
||||
}
|
||||
|
||||
export default path;
|
||||
@@ -1,5 +0,0 @@
|
||||
import express, { Router } from "express";
|
||||
|
||||
const router: Router = express.Router();
|
||||
|
||||
export default router;
|
||||
@@ -1,3 +0,0 @@
|
||||
import router from "../router";
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user