Skip to content

Lissone/point-control-api

Repository files navigation

PointControl - Api

Description   |    Demonstrations   |    Requirements   |    Technologies   |    Usage   |    Contributors


License Repo size Top lang Stars repo Forks repo Pull requests Last commit

Report bug · Request feature


Description

This project is the Back-end (Api) of a company point control application. To illustrate in a simple way, this api controls and stores all employee data, entry points, exit, pause, absences from work and all this being managed by employees of the company itself, who have specific and special credentials for this.

Project developed as an activity of my bachelor's degree in information systems, with the main objective of having a very descriptive and extensive documentation, for anyone to understand the features and learn from it. The api framework was built on clean architecture and documented with Swagger.

To facilitate the development of the project and better describe everything that was created, a flowchart of some of the project's features and relevant information at the time of its development was designed, using Whimsical.

To access the other projects integrated to this one, access:

This project was done in partnership with:

Demonstrations

Front-end to admin users

2022-10-10.15-45-34.mp4

Front-end to employees

2022-10-26.20-55-54.mp4

Requirements

Technologies

  • Nodejs
  • Typescript
  • Express
  • TypeORM
  • IoRedis
  • Nodemailer
  • Swagger (Documentation)
  • Eslint
    • Airbnb-config with another pessoal rules
    • Import helpers plugin
  • Prettier
  • Commitizen

Usage

You can clone it on your pc using the command:

git clone https://github.com/Lissone/pointControl-api.git
cd pointControl-api

Initial settings before running project

Because we use external services, it is necessary to make some simple configurations before running the project.

Database configuration

You must create the database before running an api (dbPointControl).

// .\src\external\database\dbConfig.ts

const connection = createConnection({
  type: 'mssql',
  host: process.env.DB_HOST,
  port: 1433,
  username: process.env.DB_USERNAME,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  entities: [**Entities**],
  synchronize: true,
  logging: false,
  options: {
    enableArithAbort: true
  }
})

Need create first global admin user:

Default password: 123456

INSERT INTO [dbo].[user]
(id, name, email, password, role, first_access, company_cnpj, created_at, updated_at)
VALUES (
  '08e5ad8d-5fa3-41a2-a732-b997336b4cf5',
  'Global Admin',
  'admin@admin.com',
  '$2a$05$MG6XoOEDPjtXVesTW8P2S.UkNzii1ai7VEAvBnToDHZq03sSij2vi',
  'global.admin',
  1,
  NULL,
  '2001-12-11T22:30:00Z',
  '2001-12-11T22:30:00Z'
)

Email configuration

If you are using your gmail account to use the messaging system with Nodemailer, you should give access to your account to less secure apps, even though they are secure.

Need to add environment variables:

# .\.env

# DEFAULT
# APP
APP_PORT=5000
APP_NAME=point-control-api
APP_VERSION=0.0.0

# AUTH
SECRET_KEY=super_scret # JWT secret key

# REDIS
REDIS_HOST=localhost
REDIS_PORT=6379

# DATABASE
DB_USERNAME=sa
DB_PASSWORD=123456
DB_NAME=dbPointControl
DB_HOST=localhost

# NODEMAILER
NODEMAILER_USER= # Email used for sending messages
NODEMAILER_PASS= # Your email password

If you have Docker, and want to run the container, use the command:

# Build the project container
docker-compose build
# Up container
docker-compose up

Install dependencies using:

yarn
#or
npm install

Run api:

yarn dev
#or
npm run dev

Contributors

Thanks goes to these wonderful people, who were part of the project from start to finish:

Moises Morais photo
Moises Morais
Stenio Rapchan photo
Stenio Rapchan
Vinicius Almeida photo
Vinicius Almeida

License

Distributed under the MIT License. See LICENSE for more information.