feat: Add API key support

This commit is contained in:
2023-06-20 01:47:00 +02:00
parent 5c1ed32cb6
commit eac88b2ec3
14 changed files with 406 additions and 75 deletions

View File

@ -1,55 +1,36 @@
# Astro Starter Kit: Basics
# Fi3D Slicer as a Service
```
npm create astro@latest -- --template basics
```
## API key
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json)
add `Authorization: Bearer {token}`
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## API Endpoints
![basics](https://user-images.githubusercontent.com/4677417/186188965-73453154-fdec-4d6b-9c34-cb35c248ae5b.png)
| endpoint | method | permission required | cookie access | api access | Description |
| :----------------------------: | :----: | :-----------------: | :-----------: | :--------: | :---------------------------------------: |
| /api/v1/users | GET | user.list | no | no | List every user accounts |
| /api/v1/users | POST | user.create | no | no | Create a new account |
| /api/v1/users/{userId} | GET | user.get | yes | yes | Get a user's informations |
| /api/v1/users/{userId} | PUT | user.set | yes | yes | Set a user's informations |
| /api/v1/users/{userId}/configs | GET | configs.get | yes | yes | get the list of the user's configurations |
| /api/v1/users/{userId}/configs | POST | configs.create | yes | yes | Add a new configuration to the user |
| /api/v1/users/{userId}/keys | GET | keys.get | yes | no | get the list of API key for the user |
| /api/v1/users/{userId}/keys | POST | keys.create | yes | no | create a new API key for the user |
| /api/v1/users/{userId}/process | POST | slicing.slice | yes | yes | run the main website action |
endpoints not available through API can still be accessed by admins with the `admin.` prefix to the permission
## 🚀 Project Structure
## API Key Permissions
Inside of your Astro project, you'll see the following folders and files:
### `slicing:*` permissions related to the slicing
```
/
├── public/
│ └── favicon.svg
├── src/
│ ├── components/
│ │ └── Card.astro
│ ├── layouts/
│ │ └── Layout.astro
│ └── pages/
│ └── index.astro
└── package.json
```
| name | Description |
| :-----------: | :---------------------: |
| slicing:slice | Slice the specified STL |
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
### `configs:*` permissions related to the configuration files
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
Any static assets, like images, can be placed in the `public/` directory.
## 🧞 Commands
All commands are run from the root of the project, from a terminal:
| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:3000` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |
## 👀 Want to learn more?
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
| name | description |
| :------------: | :--------------------------------: |
| configs:create | Create a new configuration file |
| configs:get | Get an existing configuration file |