The project is generated by LoopBack.
- This is the source code for Employee Log REST API Server
- Author : Rangga Rifqi Pratama (http://www.linkedin.com/in/ranggarifqi)
- License : -
- Framework : LoopbackJS
- Datasource : MySQL
- It's recommended to Fork this repo first to your own github account.
- Clone the repo
https://github.com/[GITHUB_USERNAME]/employee-log-api.git
cd employee-log-api
npm i
- Create database manually on MySQL. Name of your choice
Asumming that you're already inside the project root
directory :
cd server
cp datasources.local.json.example datasources.local.json
or copy paste it usingExplorer
vim datasources.local.json
ornano datasources.local.json
or Open it in Text Editor- Edit it so the configuration will be like this, and change the value of [DB_NAME], etc WITHOUT the square brace [] :
{
"db": {
"name": "db",
"connector": "memory"
},
"mysql": {
"host": "127.0.0.1",
"port": 3306,
"url": "",
"database": "[DB_NAME]",
"password": "[DB_PASSWORD]",
"name": "mysql",
"user": "[DB_USER]",
"connector": "mysql"
}
}
Asumming that you're already inside root
directory :
cd server
node create-mandatory-tables
- It will runs and show these :
Loopback tables 'Users' updated in mysql
Loopback tables 'RoleMapping' updated in mysql
Loopback tables 'AccessToken' updated in mysql
Loopback tables 'Role' updated in mysql
Loopback tables 'ACL' updated in mysql
- After you see above notification, Press
Ctrl+C
orCmd+C
to terminate. Because it will stuck node create-default-roles
, and you will see
Role direktur created
Role manager created
Role pegawai created
node create-default-users
, and you will see
User [email protected] found / created
>> Role director assigned to user [email protected]
User [email protected] found / created
>> Role manager assigned to user [email protected]
User [email protected] found / created
>> Role pegawai assigned to user [email protected]
Asumming that you're already inside root
directory :
node .
- You will see this notification :
Loopback tables 'Journals' updated in mysql
- The server will be running at
http://localhost:3000
- To open API Explorer, goto
http://localhost:3000/explorer
- To use the API, use this URL
http://localhost:3000/api/[MODEL]