-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1bee02f
Showing
9 changed files
with
727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/* | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# typescript-node-boilerplate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.