setup backend project structure
This commit is contained in:
18
backend/src/index.ts
Normal file
18
backend/src/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
import * as routes from "./routes"
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const port = process.env.SERVER_PORT || 8080;
|
||||
const app = express();
|
||||
|
||||
// Configure routes
|
||||
routes.register(app);
|
||||
|
||||
|
||||
// start the Express server
|
||||
app.listen(port, () => {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log( `server started at http://localhost:${port}` );
|
||||
} );
|
||||
24
backend/src/routes/index.ts
Normal file
24
backend/src/routes/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as express from "express";
|
||||
|
||||
export const register = (app: express.Application) => {
|
||||
// define a route handler for the default home page
|
||||
app.get("/", (req: any, res) => {
|
||||
res.send("Welcome Home");
|
||||
});
|
||||
|
||||
// // define a secure route handler for the login page that redirects to /guitars
|
||||
// app.get( "/login", oidc.ensureAuthenticated(), ( req, res ) => {
|
||||
// res.redirect( "/guitars" );
|
||||
// } );
|
||||
//
|
||||
// // define a route to handle logout
|
||||
// app.get( "/logout", ( req: any, res ) => {
|
||||
// req.logout();
|
||||
// res.redirect( "/" );
|
||||
// } );
|
||||
//
|
||||
// // define a secure route handler for the guitars page
|
||||
// app.get( "/guitars", oidc.ensureAuthenticated(), ( req: any, res ) => {
|
||||
// res.render( "guitars" );
|
||||
// } );
|
||||
};
|
||||
Reference in New Issue
Block a user