69 lines
1.7 KiB
Markdown
69 lines
1.7 KiB
Markdown
# Galleria con json-server e protetto con JWT
|
|
|
|
## Installazione
|
|
|
|
clonare questa repo e installare tutte le dipendenze con `npm ci`
|
|
|
|
|
|
## Start/Stop servers
|
|
|
|
| Description | Script |
|
|
| ------------------------- | -------------------- |
|
|
| Start server senza auth | `npm start-no-auth` |
|
|
| Start server con auth | `npm run start` |
|
|
|
|
## Tools
|
|
|
|
| Description | Script |
|
|
| ------------------------------ | ------------------- |
|
|
| Generate user hashed passwords | `npm run hash` |
|
|
|
|
|
|
[json-server api reference](https://github.com/typicode/json-server)
|
|
|
|
## Come usarlo
|
|
|
|
clonare e poi installare con
|
|
|
|
```
|
|
npm ci
|
|
```
|
|
|
|
nel file .env ci sono tutti i dati da modificare
|
|
|
|
poi inserire in user.json user e password utilizzati per fare il login
|
|
|
|
la password da inserire è criptata e viene generata con npm run hash
|
|
|
|
il nome viene utilizzato come cartella da scansionare, si trova dentro photos
|
|
|
|
es:
|
|
```
|
|
name: Fabio
|
|
|
|
public/photos
|
|
└── Fabio
|
|
└── original
|
|
└── 2017Irlanda19-29ago
|
|
├── IMG_0092.JPG
|
|
├── IMG_0099.JPG
|
|
├── IMG_0100.JPG
|
|
```
|
|
poi dentro Fabio genererà thumbs con tutti i thumbs
|
|
|
|
- npm run start
|
|
- su IP:4000 ci sarà la galleria e andando su impostazioni si potrà fare lo scan di tutte le foto
|
|
|
|
dopo aver fatto lo scan è possibile richiedere il json al server con tutte le informazioni anche senza autorizzazione
|
|
|
|
basta farlo partire con npm run start-no-auth e le info si possono vedere con
|
|
|
|
ip:4000/photos
|
|
|
|
- npm start
|
|
|
|
|
|
---
|
|
|
|
Inspired in this [post](https://www.techiediaries.com/fake-api-jwt-json-server/) by [Techiediaries](https://www.techiediaries.com/)
|
|
|