No description
Find a file
2026-02-22 23:38:33 +01:00
api_v1 2 2026-02-22 23:38:33 +01:00
public 2 2026-02-22 23:38:33 +01:00
.env first commit 2026-02-22 22:25:00 +01:00
.gitignore first commit 2026-02-22 22:25:00 +01:00
db.json first commit 2026-02-22 22:25:00 +01:00
index.html first commit 2026-02-22 22:25:00 +01:00
license.md first commit 2026-02-22 22:25:00 +01:00
package-lock.json first commit 2026-02-22 22:25:00 +01:00
package.json first commit 2026-02-22 22:25:00 +01:00
readme.md 2 2026-02-22 23:38:33 +01:00

Protected REST API with json-server and JWT

This project allows us to use an API Rest to develop in the frontend with mock datas before the backend is finished.

Install

Clone this repo on your machine and before run npm ci to install all dependences.

Start/Stop servers

Description Script
Start server without auth npm start-no-auth
Start server with auth npm run start

Tools

Description Script
Generate user hashed passwords npm run hash

Endpoints for auth server

Endpoint Description
localhost:4000/auth/login Login user
localhost:4000/photos Products list (token needed)

Open admin website

http://ip:4000

Change port

in package.json mod -p 4000

json-server api reference

How use

  • npm run start-auth
  • utilizzare index.html per leggere le foto

without auth

  • npm start

Inspired in this post by Techiediaries