Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server re-build with latest AdonisJS framework & Typescript #47

Merged
merged 87 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
b4e1aa6
chore: setup first basis structure
cino Dec 11, 2022
0a89427
chore: ensure styling is loaded correctly
cino Jul 16, 2022
2ca3a79
chore: comply to new routing syntax by replace . with / in routes/res…
cino Jul 17, 2022
1b6339f
chore: add login controller
cino Jul 17, 2022
da871a1
chore: correctly use views with slash instead of dot
cino Jul 17, 2022
aee63a0
chore: working login + tests
cino Jul 17, 2022
c03c31b
chore: clean up tests
cino Jul 17, 2022
0a33a88
chore: add password-forgot endpoint and matching test
cino Jul 17, 2022
0cd8f9d
chore: add delete page test
cino Jul 18, 2022
4019919
chore: add logout test
cino Jul 18, 2022
e764749
chore: add reset-password route and tests
cino Jul 19, 2022
f9dbe0b
chore: remove obsolete comment
cino Jul 19, 2022
9fdd729
chore: add account-page and tests
cino Jul 19, 2022
34c455c
chore: add data page & first step of the test
cino Jul 19, 2022
c5fb896
chore: add transfer/import data feature and tests
cino Jul 19, 2022
f8e95ab
chore: add export and basic test
cino Jul 20, 2022
aede883
chore: add all static api routes with tests
cino Jul 20, 2022
6c685ca
Regenerate 'pnpm-lock.json' and fix bad merge conflict
vraravam Dec 9, 2022
253ec12
easier dev and test runs
balajiv113 Dec 16, 2022
fd0e6f7
- remove --require-pragma from reformat-files so formatting works pro…
mcmxcdev Jul 29, 2023
6945369
- update to latest node and pnpm versions
mcmxcdev Jul 29, 2023
cf356ed
- update eslint config
mcmxcdev Jul 29, 2023
fbce220
- add test command to prepare-code
mcmxcdev Jul 29, 2023
d6d2156
fix node and pnpm dependency update
SpecialAro Aug 24, 2023
46560a6
add cross env (so that we can develop on windows)
SpecialAro Aug 24, 2023
c9a732f
add signup endpoint (TODO: JWT auth)
SpecialAro Aug 24, 2023
5bffacb
Add login endpoint
SpecialAro Aug 25, 2023
14ed4ff
Add me and updateMe endpoints
SpecialAro Aug 25, 2023
39f1ca6
Add service endpoint
SpecialAro Aug 25, 2023
e0077b6
refactor: change endpoints to use jwt
SpecialAro Aug 25, 2023
21af1c0
add recipes endpoint
SpecialAro Aug 25, 2023
6ae34ff
add workspaces endpoint
SpecialAro Aug 25, 2023
5811eb6
fix web controllors for login and post import
SpecialAro Aug 25, 2023
a4fe452
Update node deps
SpecialAro Sep 3, 2023
b833d1d
Change auth middleware (for web) and exempt api from CSRF
SpecialAro Sep 6, 2023
e0a1246
Add import endpoint (franz import)
SpecialAro Sep 6, 2023
f0e923a
Fix export/import logic
SpecialAro Sep 6, 2023
2915de9
Fix service and workspace data in user/data
SpecialAro Sep 27, 2023
f93cbb2
Fix partial lint
SpecialAro Sep 27, 2023
5ce28f8
chore: workaround lint issues
SpecialAro Sep 27, 2023
89f884e
fix: migration naming had two .
SpecialAro Sep 27, 2023
7686dee
Sync back node with recipes repo
SpecialAro Sep 7, 2023
f9cb58e
Temporarily ignore typescript
SpecialAro Sep 7, 2023
633d9f7
Fix adonisrc to handle public folder static assets
SpecialAro Sep 8, 2023
195dd98
Fix issue with production database
SpecialAro Sep 27, 2023
7dccbe5
add Legacy Password Provider
SpecialAro Sep 27, 2023
271dc91
Fix lint errors
SpecialAro Sep 27, 2023
d98b783
Fix issue on login errors frontend
SpecialAro Sep 27, 2023
8b60087
add Legacy Password Provider
SpecialAro Sep 27, 2023
e64b6ca
Fix issue with customIcons
SpecialAro Sep 27, 2023
fb8ddd6
Fix issue with auth tokens
SpecialAro Sep 27, 2023
51795dc
Update 'node' to '18.18.0'
SpecialAro Sep 28, 2023
6f2a2a9
make docker work
SpecialAro Sep 28, 2023
5f19323
improve docker entrypoint (test api performance)
SpecialAro Sep 28, 2023
277be71
Add migration database script
SpecialAro Sep 28, 2023
cbff740
NODE_ENV on recipes
SpecialAro Sep 28, 2023
c4ba028
prefer @ts-expect-error over @ts-ignore
SpecialAro Sep 28, 2023
b7b80c1
small fixes
SpecialAro Sep 28, 2023
810f57d
Update 'pnpm' to '8.7.6'
SpecialAro Sep 28, 2023
0bd83e1
fix error catch
SpecialAro Sep 28, 2023
223228f
Automatically generate JWT Public and Private keys
SpecialAro Sep 28, 2023
e7a2830
Use custom Adonis5-jwt
SpecialAro Sep 30, 2023
a0572ea
Update code to use secret (old way, no breaking changes)
SpecialAro Sep 30, 2023
550adba
Normalize appKey
SpecialAro Sep 30, 2023
7b2a8b9
Trick to make JWT tokens on client work with new version
SpecialAro Sep 30, 2023
721e421
Fix error with new JWT logic
SpecialAro Sep 30, 2023
103be71
Change migration and how we store JWT
SpecialAro Sep 30, 2023
cb7a908
Fix 500 response code (needs to be 401)
SpecialAro Sep 30, 2023
293372f
Improve logic and fix bugs
SpecialAro Oct 1, 2023
e04554b
Fix build and entrypoint logic
SpecialAro Oct 1, 2023
8b54515
Catch error if appKey changes
SpecialAro Oct 1, 2023
5107c3a
Add newToken logic
SpecialAro Sep 30, 2023
34bd8b2
Fix lint (ignore any errors)
SpecialAro Oct 1, 2023
58c9bed
Add build for PRs
SpecialAro Oct 1, 2023
f36350a
pnpm reformat-files result
SpecialAro Oct 1, 2023
53ef574
Fix some tests
SpecialAro Oct 1, 2023
46e10df
Fix reset password not working (test failing)
SpecialAro Oct 2, 2023
af8694f
Restore csrfTokens (disabled by accident)
SpecialAro Oct 2, 2023
88547ed
Fix pnpm start command with .env
SpecialAro Oct 2, 2023
42b678b
Disable failing tests on the transfer endpoint (TODO)
SpecialAro Oct 2, 2023
0bf0f1c
Add tests to PR build
SpecialAro Oct 2, 2023
c8bb323
Fix build
SpecialAro Oct 2, 2023
7afa4e1
Remove unnecessary assertStatus
SpecialAro Oct 2, 2023
5cbb426
Add typecheck
SpecialAro Oct 2, 2023
34c0344
hash password on UserFactory (fix build)
SpecialAro Oct 2, 2023
291a235
Add JWT_USE_PEM true by default (increase security)
SpecialAro Oct 13, 2023
1f3aafb
fix name of github action
SpecialAro Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .adonisrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"typescript": true,
"commands": [
"./commands",
"@adonisjs/core/build/commands/index.js",
"@adonisjs/repl/build/commands",
"@adonisjs/lucid/build/commands",
"@adonisjs/mail/build/commands",
"adonis5-jwt/build/commands"
],
"exceptionHandlerNamespace": "App/Exceptions/Handler",
"aliases": {
"App": "app",
"Config": "config",
"Database": "database",
"Contracts": "contracts"
},
"preloads": ["./start/routes", "./start/kernel", "./start/events"],
"providers": [
"./providers/AppProvider",
"@adonisjs/core",
"@adonisjs/view",
"@adonisjs/lucid",
"@adonisjs/auth",
"@adonisjs/shield",
"@adonisjs/session",
"@adonisjs/mail",
"adonis5-jwt",
"./providers/LegacyHasherProvider"
],
"aceProviders": ["@adonisjs/repl"],
"tests": {
"suites": [
{
"name": "functional",
"files": ["tests/functional/**/*.spec(.ts|.js)"],
"timeout": 60000
}
]
},
"testProviders": ["@japa/preset-adonis/TestsProvider"],
"metaFiles": [
{
"pattern": "resources/views/**/*.edge",
"reloadServer": false
},
{
"pattern": "public/**",
"reloadServer": false
}
]
}
46 changes: 0 additions & 46 deletions .do/deploy.template.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ docker
node_modules
.husky

# Ignore data folder
data
tmp

# Ignore recipes folder (it is pulled in the image by git)
recipes

# Ignore build folder
build
15 changes: 15 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#This is a minimal needed configuration for development

NODE_ENV=development
APP_URL=http://localhost:3333
DB_CONNECTION=sqlite
APP_KEY=IDU2cMbrvS6iv5841YmFJSjnIqT1X1Nx

# These are needed if running outside of Docker
HOST=127.0.0.1
PORT=3333

IS_CREATION_ENABLED=true
IS_DASHBOARD_ENABLED=true
IS_REGISTRATION_ENABLED=true
CONNECT_WITH_FRANZ=true
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#This is a example file with all the available configuration options.

NODE_ENV=development
APP_URL=localhost
DB_CONNECTION=sqlite
Expand All @@ -19,8 +21,6 @@ IS_DASHBOARD_ENABLED=true
IS_REGISTRATION_ENABLED=true
CONNECT_WITH_FRANZ=false
DATA_DIR=data
PUID=1000
PGID=1000

# These are needed if running outside of Docker
APP_KEY= # Need to set some value
Expand Down
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#This is a minimal needed configuration for test

NODE_ENV=test
ASSETS_DRIVER=fake
SESSION_DRIVER=memory
APP_KEY=IDU2cMbrvS6iv5841YmFJSjnIqT1X1Nx
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ node_modules
/recipes/

# package files
package.json
pnpm-lock.yaml

# Json
*.json
tests/functional/dashboard/import-stubs/invalid.json
97 changes: 75 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,86 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
env: {
commonjs: true,
es6: true,
node: true,
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
},
extends: ['airbnb-base'],
ignorePatterns: ['node_modules', 'build', 'recipes', '.eslintrc.js'],
extends: [
'plugin:adonis/typescriptApp',
'plugin:unicorn/recommended',
'prettier',
],
plugins: [],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
use: 'readonly',
window: 'readonly',
document: 'readonly',
ENV: 'readonly',
session: 'readonly',
response: 'readonly',
use: true,
},
parserOptions: {
ecmaVersion: 2018,
env: {
es6: true,
node: true,
},
reportUnusedDisableDirectives: true,
overrides: [
{
files: ['**/*.ts'],
extends: [
'plugin:adonis/typescriptApp',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/strict',
// TODO: Opt-in to a stricter ruleset in the future
// 'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
plugins: [],
rules: {
// eslint
'max-len': 0,

// @typescript-eslint
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/semi': 0,
'@typescript-eslint/space-before-function-paren': 0,
'@typescript-eslint/no-extraneous-class': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/prefer-ts-expect-error': 0,
},
},
],
rules: {
'arrow-parens': 0,
'class-methods-use-this': 0,
eqeqeq: 1,
'implicit-arrow-linebreak': 0,
// eslint
'array-callback-return': 1,
'consistent-return': 1,
'max-len': 0,
'no-await-in-loop': 1,
'no-restricted-syntax': 0,
'operator-linebreak': 0,
'object-curly-newline': 0,
'no-return-assign': 1,
'no-console': [
1,
{
allow: ['warn', 'error'],
},
],
'no-param-reassign': 1,
'prefer-destructuring': 1,
// eslint-plugin-unicorn
'unicorn/filename-case': 0,
'unicorn/prefer-module': 0,
'unicorn/prevent-abbreviations': 0,

'unicorn/import-style': [
2,
{
styles: {
path: {
named: true,
},
},
},
],
'unicorn/no-empty-file': 0,
'unicorn/prefer-top-level-await': 0,
},
};
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: AdonisJS check

on:
pull_request:
branches: [main]

jobs:
adonis-js-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js specified in the '.nvmrc' file
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Install pnpm
run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v

- run: pnpm install

- run: pnpm typecheck

- run: pnpm lint

- run: pnpm test

- run: pnpm run build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ tags

# Adonis directory for storing tmp files
tmp
build
public/assets

# Environment variables, never commit this file
.env
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ FILE_NAME="$(dirname "$0")/_/husky.sh"
if [ -f $FILE_NAME ]; then
. $FILE_NAME
pnpm prepare
pnpm lint
pnpm prepare-code
fi
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
save-exact = true
engine-strict = true
unsafe-perm = true
legacy-peer-deps = true
frozen-lockfile = false
4 changes: 2 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import("prettier").Options} */
module.exports = {
singleQuote: true,
arrowParens: 'avoid',
trailingComma: 'all',
}
};
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COPY . /server-build
ENV CI=true
RUN PNPM_VERSION=$(node -p 'require("./package.json").engines.pnpm'); npm i -g pnpm@$PNPM_VERSION
RUN pnpm install --config.build-from-source=sqlite --config.sqlite=/usr/local
RUN pnpm build

# ---- RUNTIME IMAGE ----------------------------------------------------------
FROM node:18.18.0-alpine
Expand All @@ -19,7 +20,9 @@ LABEL maintainer="ferdium"
# TODO: Shouldn't we set 'NODE_ENV=production' when running in production mode?
ENV HOST=0.0.0.0 PORT=3333 DATA_DIR="/data"

RUN apk add --no-cache sqlite-libs curl su-exec python3 make g++ py3-pip git py3-pip
RUN apk add --no-cache sqlite-libs curl su-exec python3 make g++ py3-pip git py3-pip sqlite
# The next command is needed for sqlite3 install command executed by node-gyp
# RUN ln -s /usr/bin/python3 /usr/bin/python


COPY --from=build /server-build /app
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center">
<p align="center">
<img src="./logo.png" alt="" width="300"/>
</p>

Expand Down
19 changes: 7 additions & 12 deletions ace
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
'use strict'

/*
|--------------------------------------------------------------------------
| Ace Commands
|--------------------------------------------------------------------------
|
| The ace file is just a regular Javascript file but with no extension. You
| can call `node ace` followed by the command name and it just works.
|
| Also you can use `adonis` followed by the command name, since the adonis
| global proxies all the ace commands.
| This file is the entry point for running ace commands.
|
*/

const { Ignitor } = require('@adonisjs/ignitor')
require('reflect-metadata')
require('source-map-support').install({ handleUncaughtExceptions: false })

new Ignitor(require('@adonisjs/fold'))
.appRoot(__dirname)
.fireAce()
.catch(console.error)
const { Ignitor } = require('@adonisjs/core/build/standalone')
new Ignitor(__dirname)
.ace()
.handle(process.argv.slice(2))
Loading