Comments (3)
Got it thanks.
Your suggestion in the readme on some testing if anyone is interested
would be helpful, but there are a lot of resources already on testing so maybe links to ones you found particular useful would be a better use of time.
I think I have more questions then suggestions since I'm not sure what I don't know yet. I'm just reading through passport to find out how to do JWT authentication. I think with node my biggest worries are whether what I'm making is secure or not outside of HTTPS and SQL Injection. Typically, our APIs are done in Laravel, and a lot of the security is handled.
Is there a reason to setup the Express app in TypeScript without using classes? I found an example creates a class for the app instead and then loads everything up, which is what I'd do in an Angular application, but was wondering if that is a good idea for Node/Express:
app.ts
import * as express from 'express'
class App {
public express
constructor () {
this.express = express()
this.mountRoutes()
}
private mountRoutes (): void {
const router = express.Router()
router.get('/', (req, res) => {
res.json({
message: 'Hello World!'
})
})
this.express.use('/', router)
}
}
export default new App().express
Then server.ts
would only need to start the server:
server.ts
import app from './App'
const port = process.env.PORT || 3000
app.listen(port, (err) => {
if (err) {
return console.log(err)
}
return console.log(`server is listening on ${port}`)
})
from typescript-node-starter.
This isn't a mistake, but I thought it might make it clear for those who didn't read the readme that node_modules/*
is included by default. So effectively this line does nothing.
I'd definitely be open to removing it. What do you think?
Glad you found this helpful. Any ideas for improvements?
from typescript-node-starter.
That's a great idea. I'll post some of the links that I found helpful on testing when I get a chance.
On the security front, I am far from an expert so I'll leave those questions for someone more knowledgeable.
As far as classes go, classes are perfectly valid. The only reason I didn't use them here is because most people set up their express apps without them so I want the code to look familiar. In addition, some people believe TypeScript forces you to use classes, and I find it to debunk that myth.
from typescript-node-starter.
Related Issues (20)
- README link to TypeScript Website's documentation is broken HOT 1
- client ts files and server ts files should compile to diffrent target HOT 3
- None of the tests pass. HOT 3
- Upgrade to TS 4.0 HOT 6
- Live demo is not working HOT 1
- :( Application Error If you are the application administrator, you can access the diagnostic resources. HOT 3
- Add a sample azure-pipelines.yml HOT 2
- Cannot read property 'picture' of undefined HOT 2
- Upgrade the connect-mongo package to v4 HOT 1
- To add more topics to this repository
- Checked out from master and audit still reported high severity vulnerability found.
- [Node] MongoError: E11000 duplicate key error collection HOT 1
- MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017 HOT 1
- Cannot GET /favicon.ico HOT 2
- Error(s) on update dependencies HOT 2
- The README.md live demo link is broken HOT 3
- User.ts - why Pre Middleware instead of setter for password? HOT 1
- Cannot find tsconfig.test.json HOT 1
- build failed HOT 4
- Error in development mode: req.session.returnTo = req.path; HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-node-starter.