clone the repository by using
git clone https://github.com/devadeboye/mini-twitter-backend.git
After cloning the repository, install all dependencies using
yarn install
Then you can start the server using
yarn start
Start it in development mode using
yarn start:dev
and in debug mode using
yarn start:debug
The application connects to a postgresql databasse.
See the graphql playground UI by visiting
http://localhost:YOUR_PORT/graphql
To make a route require authentication, use the @useToken
decorator.
To get the data in a logged in user token, use the @UserTokenData
decorator. e.g
@Query()
@UseToken()
async getUser(
@Args('id') id: string,
@UserTokenData() tokenData: TokenData
) {
// then you can do whatever you want with token data
Logger.log(tokenData.sub);
return this.userService.findOneBy({ id });
}
To create migrations, run the code below on your terminal
yarn run migration:create THE_MIGRATION_FILENAME
Where THE_MIGRATION_FILENAME is the name to give to the migration file. e.g
yarn run migration:create this-is-a-test
To run migrations run the code below on your teminal:
yarn run migration:run
yarn run migration:revert