Skip to content

Commit

Permalink
firt commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuryahyd committed Nov 13, 2018
0 parents commit 1bee02f
Show file tree
Hide file tree
Showing 9 changed files with 727 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/*
build/*
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# typescript-node-boilerplate
29 changes: 29 additions & 0 deletions lib/App.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// import express = require("express");
import express from 'express';
import path = require('path');

import chatRoutes from './routes';
import { Application } from 'express-serve-static-core';

class App {
public server: Application;
constructor() {
this.server = express();
this.mountRoutes();
}

private mountRoutes(): void {
const router = express.Router();
router.get("/root/:something?", (req, res) => {
res.json({
success: true,
path: `app path ${req.params.something||''}`
});
});

this.server.use(router);
this.server.use(chatRoutes)
}
}

export default new App().server;
8 changes: 8 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import app from "./App";

app.listen(3000, (err: Error) => {
if (err) {
return console.error(err);
}
console.log("running on port 3000");
});
16 changes: 16 additions & 0 deletions lib/routeHandlers/chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Request,Response} from 'express';

interface Chat{
id:String
}

class ChatRoutes {
public getAllChats(req:Request,res:Response){
res.json({
success:true,
chats:[{id:'x,vnxki'}]
});
}
}

export default new ChatRoutes();
7 changes: 7 additions & 0 deletions lib/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import chatRoutes from "./routeHandlers/chat";
import Router from 'express';

const router = Router();
router.get('/allChats',chatRoutes.getAllChats);

export default router;
Loading

0 comments on commit 1bee02f

Please sign in to comment.