This is a backend of a simple blog(realworld) built with nestjs.
- Feature of app(API Spec)
- User Module(Register/Login/Follow)
- Article Module(CURD of article/favorite/tag)
- Comment Module(CRD of comments)
- Authentication(jwt, AuthGuard, passport)
- E2E test(jest)
- Log(middleware/interceptor)
- Module for configuration management
- Production ready configuration(docker)
- Remove useless configuration
- TestDBService for inserting predefined data into database before test starts
- ELK Logging
- E2E Refactor(Separate each test suit according to feature. Load necessary data before each test suit run.)
- Nestjs for backend framework
- Typeorm for database(Mysql) connection
- Docker for environment deployment
- Jest for test
As a frontend programmer with nearly 3 years experiences, I think it's time for me to get a better understanding of backend. So I start to build this blog, aiming to studying knowledge of dependency injection, how to design a database table, basic usage of mysql... by practice.
npm install
npm run start:docker-dev
Hold on a few seconds to wait for database finish starting up. This process will set up database both for dev and e2e test.
npm run start:mydev
Now, you are ready to get your hand dirty.
select TS main
config in the .vscode/launch.json and start debugging
Mysql log can be found in mysql-log/ directory.(PS: If you can't find any log, may be you should use the chmod
command)
npm run test:e2e
@TODO
-
never reexport *.entity Or you may easily get circular dependency error or entity metadata not found error(typeorm/typeorm#420)
-
AuthGuard injection quirks?(ref Module definition of JwtOptionalGuard)
-
In Jest's beforeAll(), runtime error is swallowed
-
Interceptor/Guard/middleware do not have to declare in modules.
https://stackoverflow.com/questions/27067251/where-to-store-jwt-in-browser-how-to-protect-against-csrf/37396572 ab -n 10000 -c100 -T application/json -p /tmp/ab-post-data.json localhost:3000/users/