System for employees to clock in / out with query functions.
Please see https://fhmclockinsys.docs.apiary.io/
Postman Collection is prepared and stored in /postman
. Import the folder to Postman to start calling API.
An environment Local Dev
is created to call localhost
server. Change the server_url
to a suitable one or create a new environment.
A .env
file at root directory is always necessary for this system to run regardless of envrionment.
Before deployment, prepare the .env
file with following parameters or check .env.template
.
# == Database ==
MYSQL_HOST=
MYSQL_PORT=
MYSQL_DB_NAME=
MYSQL_USER=
MYSQL_PASSWORD=
# Path to JSON file containing data to be inserted in DB when startup, e.g. ./data/member.json. Can be empty
DEFAULT_FILE_PATH=
# == API ==
# Port number that the server is listening to
SERVER_PORT=
# For api versioning and will affect the URL that server is listening, /api/{API_VERSION}/xxx
API_VERSION=
Docker Compose is used to start a MySQL DB together with this system.
-
Change the database password to a strong one in
docker-compose.yml
for security reason.environment: - TZ=Asia/Taipei - MYSQL_DATABASE=c - MYSQL_USER=sys_admin - MYSQL_PASSWORD=[CHANGE TO STRONG PASSWORD] - MYSQL_ROOT_PASSWORD=[CHANGE TO STRONG PASSWORD]
-
Create the
.env
file as mentioned.- Suffix can be added to identified in which environment this file is used. For example, name it
.env.docker
- Remember to change
MYSQL_PASSWORD
to the one used in step 1.
- Suffix can be added to identified in which environment this file is used. For example, name it
-
Update the
env_file
indocker-compose.yml
to the filename of the.env
file created. Default is.env.docker
. -
Run the containers by
docker-compose up -d
-
May need to wait for several minutes for the MySQL server to start and the system to connect to it.
-
Server should be listening to port 3000 and waiting for incoming calls.
-
Prepare a MySQL Server, with
database
created. For example,CREATE DATABASE clock_in_out_system;
-
Create the
.env
file as mentioned. -
Run the
npm
commandsnpm install npm run start
-
Server should be listening to port 3000 and waiting for incoming calls.