Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nico-martin/critical-css-api
This nodeJS app provides a simple API to generate the Critical CSS from a given URL. It also has a whole user management based on MongoDB where users can create and delete projects.
https://github.com/nico-martin/critical-css-api
Last synced: about 1 month ago
JSON representation
This nodeJS app provides a simple API to generate the Critical CSS from a given URL. It also has a whole user management based on MongoDB where users can create and delete projects.
- Host: GitHub
- URL: https://github.com/nico-martin/critical-css-api
- Owner: nico-martin
- License: mit
- Created: 2018-08-11T20:04:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-22T13:37:36.000Z (about 2 years ago)
- Last Synced: 2024-08-03T13:04:31.295Z (5 months ago)
- Language: TypeScript
- Homepage: https://api.critical-css.io/
- Size: 1.94 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
Critical CSS API
======================
This nodeJS app provides a simple API to generate the Critical CSS from a given URL.
https://api.criticalcss.io**Version 2** introduces a whole user management based on MongoDB where users can create and delete projects.
## Env
The following env variables are required to use the app:
* **DATABASE_URL**: the host of the MongoDB
* **MASTER_KEY**: a private Key to identify as Master user
* **JWT_SECRET**: a private Key to generate and verify JSON Web Tokens## Authentification
All requests except the `generate Critical CSS` require a Bearer Token for authentification.
This can be a JWT to authenticate as a user (restricted access to elements "owned" by the user) or the MASTER_KEY from the env vars to identify as "master" and have full access.## Routes
### generate Critical CSS
```POST: https://your-project-host.com:9092/```
```
{
"token": ":projectToken"
"url" : "https://sayhello.ch",
"dimensions": {
"desktop": {
"width":1200,
"height": 800
},
"tablet" : {
"width":700,
"height": 300
}
}
}
```### Get all users
```GET: https://your-project-host.com:9092/user/```### Get single user
```GET: https://your-project-host.com:9092/user/:userID/```### Create user
```PUT: https://your-project-host.com:9092/user/```
```
{
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"password": "xyz"
}
```### Update user
```PUT: https://your-project-host.com:9092/user/:userID/```
```
{
"lastname": "Muster",
"password": "hello"
}
```### Delete user
```DELETE: https://your-project-host.com:9092/user/:userID/```### User SignIn
```POST: https://your-project-host.com:9092/user/signin/```
```
{
"email": "[email protected]",
"password": "hello"
}
```### Update user credits
```PUT: https://your-project-host.com:9092/credits/```
```
{
"userID": 2,
"credits": "100"
}
```### User JWT validate
```GET: https://your-project-host.com:9092/user/jwt/validate/```### Add Project
```PUT: https://your-project-host.com:9092/project/```
```
{
"url": "https://sayhello.ch",
"userID": 2
}
```### Delete Project
```DELETE: https://your-project-host.com:9092/project/:projectID/```