Live Demo ๐ฅ:
- Client: https://simple-login-client.herokuapp.com/
- Service: https://simple-login-services.herokuapp.com/
Note: be patient if it slow, because I'm using free tier Heroku.
There two di app that need to be run, services and client.
This service use Postgres
as its DB so install it first on your machine if you don't have. Also install sequelize-cli
by running this command.
npm i -g sequelize-cli
This will add sequelize-cli
in global.
go to server directory and install all its dependecies
cd server
npm install
Make sure your database ready. If you don't have database yet, create one. You can change service configuration for database in server/config/config.json
. By default the configuration for development will look like this. Change the value if you need it.
{
"development": {
"username": "postgres",
"password": "postgres",
"database": "database_development",
"host": "localhost",
"dialect": "postgres"
},
}
After your database is running, migrate the table by running this command. (make sure you are still in server
directory).
npx sequelize-cli db:migrate
That commnand will create the table needed for you.
Run the server by using start
command
npm run start
By default it will run at http://localhost:3000.
- Show user list:
GET /api/user
- Show user by id:
GET /api/:id
- Create user:
POST /api/user
- Update user by id:
PUT /api/user/:id
- Delete user by id:
DELETE /api/user/:id
- Login:
POST /api/auth
Go to client directory and create env
file
cd client
touch .env.development.local
That command will create env
file for you. Open it and add
REACT_APP_SERVER_API=<your-server-host>
You can change <your-server-host>
, for example if you previously run server at http://localhost:3000
, you can add this in env
file
REACT_APP_SERVER_API=http://localhost:3000
go to server directory and install all its dependecies (we assume you still in client
directory )
npm install
Run the client by using start
command
npm run start
By default it will run at http://localhost:3000.
NOTE: if you previously run server first, it it will asked you if you want to run with other port (let's assume that server will take port 3000 so it will suggest you to take port 3001 for client to run).
To test the client, you can use
npm run test
or if you want to see the coverage, you can use
npm run test -- --coverage
- Express
- Postgress
- Sequelize
- Express-Validator
- React
- Ant-Design
- Axios
- @testing-library