A users, companies and vacancies management project developed with Nestjs, GraphQL, mongoDB and docker.
A BFF server connected with 3 services (users, companies, vacancies) achieving the functionalities of user login and signup, retrieving users, posting and retrieving companies and CRUD of vacancies.
- Use Nestjs CLI to generate RESTful and GraphQL resources
- Use
ConfigService
to centralize environment variables in different stages - Use
AuthGuard
andRolesGuard
to decorate protected controllers or the routers - Use
Passport
local strategy and JWT strategy for authentication and authorization. - Use
schemaProvider
to hook 'pre save' to save hashed password - Use
Interceptor
to setauthorization
bearer token to HttpService - Use
nestjs-command
to run seeding scripts - Use
docker
to containerize the app and support hot reload development - Use
Jest
to unit test - Use
gitmoji
to bring fun and meaningful commit.
# container build
$ cp .env.development .env && docker-compose up
# switch to another terminal
# seed users
$ docker-compose exec user-service npm run seed:users
# seed companies
$ docker-compose exec company-service npm run seed:companies
# seed vacancies
$ docker-compose exec vacancy-service npm run seed:vacancies
GraphQL playground is running at http://locahost:3000/graphql
For more GraphQL documentations, please check out here here
Please login first:
mutation {
login(loginInput: {username: "mark", password: "mark"}) {
accessToken
}
}
Set the accessToken
to header:
{"Authorization": "Bearer accessToken"}
- 1. A company has a name and address
query {
company(_id: "5e5df7fc6953acd3dc50fe8f"){
name
address
}
}
- 2. A company can have multiple job vacancies
query {
company(_id: "5e5df7fc6953acd3dc50fe8f"){
name
address
vacancies{
title
description
}
}
}
- 3. A company has many users
query {
company(_id: "5e5df7fc6953acd3dc50fe8f"){
name
address
users{
name
}
}
}
- 4. A vacancy has a title, description, expiredAt (datetime)
query{
vacancy(_id: "vacancyId"){
title,
description,
expiredAt
}
}
- 5. A user has a name, username, password(omitted)
query {
users{
name
username
}
}
- 6. A user belongs to one company only
query {
users{
name
companyId
}
}
- 7. A user can have two types of roles: user and admin
query {
users{
name
role
}
}
- 8. A user with an admin role can view, create, edit, and delete vacancies
mutation{
createVacancy(
createVacancyInput:
{
_id: "vacancyId",
title:"Frontend",
description:"Frontend developer",
expiredAt: "2021-10-08T02:41:36.667+00:00",
companyId: "5e5df7fc6953acd3dc50fe8f"
}
){
_id,
}
}
mutation{
updateVacancy(
updateVacancyInput:
{
_id: "vacancyId",
title:"Frontend",
description:"Frontend developer",
expiredAt: "2021-10-08T02:41:36.667+00:00"
}
){
_id,
}
}
mutation{
removeVacancy(_id: "vacancyId"){
_id,
}
}
Return 403
http status code if not permitted
-
9. A user without an admin role can view job vacancies only
By checking if the role is admin or user -
10. A user has to login first before doing any operation
Return401
http status code if not login