diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index cea9076..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,11 +0,0 @@ -image: alpine:latest - -pages: - stage: deploy - script: - - echo 'Nothing to do...' - artifacts: - paths: - - public - only: - - master diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 83312c2..923d918 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -4,7 +4,6 @@ -Date Strict-Transport-Security "max-age=31536000; includeSubDomains" - Content-Security-Policy "default-src 'self' 'unsafe-inline';" Feature-Policy "geolocation none;midi none;notifications none;push none;sync-xhr none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;" X-Content-Type-Options "nosniff" X-Frame-Options "DENY" @@ -13,7 +12,7 @@ } } -localhost { +simplenotes.be { @static { path *.css *.js file @@ -30,22 +29,32 @@ localhost { handle_errors { rewrite @404 /404.html file_server + import security } route /api/* { uri strip_prefix /api - reverse_proxy http://localhost:8081 + reverse_proxy http://api:8081 } header @static Cache-Control "public, max-age=31536000" + header Content-Security-Policy "default-src 'self' 'unsafe-inline';" encode gzip - root * /home/hubert/Workspace/Notes-TFE/frontend/dist + root * /site log import security } -www.localhost { - redir * https://localhost{path} +www.simplenotes.be { + redir * https://simplenotes.be{path} +} + +docs.simplenotes.be { + file_server + root * /docs + import security + + header Content-Security-Policy "default-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net;" } diff --git a/caddy/Caddyfile.prod b/caddy/Caddyfile.prod deleted file mode 100644 index cb9546f..0000000 --- a/caddy/Caddyfile.prod +++ /dev/null @@ -1,58 +0,0 @@ -(security) { - header * { - -Server - -Date - - Strict-Transport-Security "max-age=31536000; includeSubDomains" - Content-Security-Policy "default-src 'self' 'unsafe-inline';" - Feature-Policy "geolocation none;midi none;notifications none;push none;sync-xhr none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;" - X-Content-Type-Options "nosniff" - X-Frame-Options "DENY" - X-XSS-Protection "1; mode=block" - Referrer-Policy "no-referrer-when-downgrade" - } -} - -simplenotes.be { - @static { - path *.css *.js - file - } - - @404 { - expression {http.error.status_code} == 404 - } - - route /* { - file_server - } - - handle_errors { - rewrite @404 /404.html - file_server - import security - } - - route /api/* { - uri strip_prefix /api - reverse_proxy http://api:8081 - } - - header @static Cache-Control "public, max-age=31536000" - - encode gzip - root * /site - log - - import security -} - -www.simplenotes.be { - redir * https://simplenotes.be{path} -} - -docs.simplenotes.be { - file_server - root * /docs - import security -} diff --git a/caddy/Dockerfile b/caddy/Dockerfile index 499ee55..7dbe735 100644 --- a/caddy/Dockerfile +++ b/caddy/Dockerfile @@ -1,9 +1,19 @@ +## Docker multi-stage build + +## Generate api documentation +FROM quay.io/bukalapak/snowboard AS docbuilder +RUN mkdir /out +COPY api-doc /doc +RUN /app/packages/snowboard/bin/run html api.apib -o /out + +## Generate website +FROM node:latest AS builder +COPY frontend /app +WORKDIR /app +RUN yarn install && yarn run generate + +## Main image FROM caddy:2.0.0 - -COPY caddy/Caddyfile.prod /etc/caddy/Caddyfile - -# Copy main website -COPY frontend/dist /site - -# Copy api docs website -COPY public /docs +COPY caddy/Caddyfile /etc/caddy/Caddyfile +COPY --from=docbuilder /out /docs +COPY --from=builder /app/dist /site \ No newline at end of file diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 16062d5..0000000 --- a/public/index.html +++ /dev/null @@ -1,465 +0,0 @@ -Notes API

Notes API

Accounts

Create an account

POST http://localhost:5000/user
Requestsexample 1
Headers
Content-Type: application/json
Body
{
-  "username": "babar",
-  "email": "michel@seed-it.eu",
-  "password": "tortue"
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "username": {
-      "type": "string"
-    },
-    "email": {
-      "type": "string"
-    },
-    "password": {
-      "type": "string"
-    }
-  }
-}
Responses200409
Headers
Content-Type: application/json
Body
{
-  "message": "Created"
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "message": {
-      "type": "string"
-    }
-  }
-}
Headers
Content-Type: application/json
Body
{
-  "message": "User already exists"
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "message": {
-      "type": "string"
-    }
-  }
-}

Register a new user
POST/user


Authenticate user

Authenticate one user to access protected routing.

-
POST http://localhost:5000/user/login
Requestsexample 1
Headers
Content-Type: application/json
Body
{
-  "username": "babar",
-  "password": "tortue"
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "username": {
-      "type": "string"
-    },
-    "password": {
-      "type": "string"
-    }
-  }
-}
Responses200401
Headers
Content-Type: application/json
Body
{
-  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "token": {
-      "type": "string"
-    }
-  }
-}
Headers
Content-Type: application/json
Body
{
-  "description": "Invalid credentials",
-  "error": "Bad Request",
-  "status_code": 401
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "description": {
-      "type": "string"
-    },
-    "error": {
-      "type": "string"
-    },
-    "status_code": {
-      "type": "number"
-    }
-  }
-}

Authenticate a user
POST/user/login


Get User Info

Receive the username and email from the currently logged in user

-
GET http://localhost:5000/user/me
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Responses200
Headers
Content-Type: application/json
Body
{
-  "user": {
-    "username": "Jean",
-    "email": "abc@def.ghi"
-  }
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "user": {
-      "type": "object",
-      "properties": {
-        "username": {
-          "type": "string"
-        },
-        "email": {
-          "type": "string"
-        }
-      }
-    }
-  }
-}

Get User Info
GET/user/me


Notes

Notes

GET http://localhost:5000/notes
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Responses200
Headers
Content-Type: application/json
Body
[
-  {
-    "title": "Kotlin",
-    "tags": [
-      "Dev",
-      "Server"
-    ],
-    "updatedAt": "2020-01-20T00:00:00"
-  },
-  {
-    "title": "Java",
-    "tags": [
-      "Dev"
-    ],
-    "updatedAt": "2018-01-20T00:00:00"
-  }
-]
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "array"
-}

Get Notes
GET/notes


Note

POST http://localhost:5000/notes/Kotlin
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Body
{
-  "tags": [
-    "Dev",
-    "Server"
-  ]
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "tags": {
-      "type": "array"
-    }
-  }
-}
Responses201409
This response has no content.
This response has no content.

Create a Note
POST/notes/{noteTitle}

URI Parameters
HideShow
noteTitle
string (required) Example: Kotlin

The title of the Note.

-

GET http://localhost:5000/notes/Kotlin
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Responses200404
Headers
Content-Type: application/json
Body
{
-  "tags": [
-    "Dev",
-    "Server"
-  ],
-  "chapters": [
-    {
-      "title": "Introduction",
-      "content": "..."
-    },
-    {
-      "title": "Objects",
-      "content": "..."
-    }
-  ]
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "tags": {
-      "type": "array"
-    },
-    "chapters": {
-      "type": "array"
-    }
-  }
-}
This response has no content.

Get Note
GET/notes/{noteTitle}

URI Parameters
HideShow
noteTitle
string (required) Example: Kotlin

The title of the Note.

-

PATCH http://localhost:5000/notes/Kotlin
Requestsexample 1example 2
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Body
{
-  "title": "NewTitle"
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "title": {
-      "type": "string"
-    }
-  }
-}
Responses200404
This response has no content.
This response has no content.
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Body
{
-  "tags": [
-    "new",
-    "tags"
-  ]
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "tags": {
-      "type": "array"
-    }
-  }
-}
Responses200404
This response has no content.
This response has no content.

Update a Note
PATCH/notes/{noteTitle}

URI Parameters
HideShow
noteTitle
string (required) Example: Kotlin

The title of the Note.

-

DELETE http://localhost:5000/notes/Kotlin
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Responses200404
This response has no content.
This response has no content.

Delete Note
DELETE/notes/{noteTitle}

URI Parameters
HideShow
noteTitle
string (required) Example: Kotlin

The title of the Note.

-

Chapters

POST http://localhost:5000/notes/Kotlin/chapters/Kotlin
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Body
{
-  "title": "Chapter 1",
-  "content": "..."
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "title": {
-      "type": "string"
-    },
-    "content": {
-      "type": "string"
-    }
-  }
-}
Responses201404
This response has no content.
This response has no content.

Post a chapter
POST/notes/{noteTitle}/chapters/{chapterNumber}

URI Parameters
HideShow
noteTitle
string (required) Example: Kotlin

The title of the Note.

-
chapterNumber
number (required) Example: Kotlin

The chapter number.

-

PATCH http://localhost:5000/notes/Kotlin/chapters/Kotlin
Requestsexample 1example 2
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Body
{
-  "title": "new title"
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "title": {
-      "type": "string"
-    }
-  }
-}
Responses200404
This response has no content.
This response has no content.
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Body
{
-  "content": "..."
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "content": {
-      "type": "string"
-    }
-  }
-}
Responses200404
This response has no content.
This response has no content.

Patch a chapter
PATCH/notes/{noteTitle}/chapters/{chapterNumber}

URI Parameters
HideShow
noteTitle
string (required) Example: Kotlin

The title of the Note.

-
chapterNumber
number (required) Example: Kotlin

The chapter number.

-

DELETE http://localhost:5000/notes/Kotlin/chapters/Kotlin
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Responses200404
This response has no content.
This response has no content.

Delete a chapter
DELETE/notes/{noteTitle}/chapters/{chapterNumber}

URI Parameters
HideShow
noteTitle
string (required) Example: Kotlin

The title of the Note.

-
chapterNumber
number (required) Example: Kotlin

The chapter number.

-

Tags

Tags

GET http://localhost:5000/tags
Requestsexample 1
Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Responses200
Headers
Content-Type: application/json
Body
{
-  "tags": [
-    "Dev",
-    "Server"
-  ]
-}
Schema
{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "tags": {
-      "type": "array"
-    }
-  }
-}

Get all tags
GET/tags


Generated by aglio on 23 Apr 2020

\ No newline at end of file