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

User service #31

Merged
merged 22 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions packages/portal/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/
node_modules/
husky.js
increase-built.js
devel.js
67 changes: 67 additions & 0 deletions packages/portal/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"env": {
"commonjs": true,
"es2020": true,
"node": true
},
"extends": ["airbnb-base", "prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx", ".d.ts"]
},
"alias": {
"map": []
}
}
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["@typescript-eslint"],
"rules": {
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"class-methods-use-this": [1],
"no-underscore-dangle": [0],
"@typescript-eslint/no-unused-vars": [
2,
{
"args": "all",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"camelcase": 2,
"arrow-body-style": 0,
"no-mixed-spaces-and-tabs": 2,
"max-len": [
2,
{
"code": 120,
"tabWidth": 2,
"ignoreUrls": true
}
]
}
}
37 changes: 0 additions & 37 deletions packages/portal/.eslintrc.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions packages/portal/babel.config.cjs

This file was deleted.

4 changes: 0 additions & 4 deletions packages/portal/config.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/portal/jest-resolver.cjs

This file was deleted.

23 changes: 0 additions & 23 deletions packages/portal/jest.config.js

This file was deleted.

11 changes: 11 additions & 0 deletions packages/portal/knexfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Connector } from '@orochi-network/framework';
import type { Knex } from 'knex';
import appConfig from './src/helper/config';

// Update with your config settings.

const config: { [key: string]: Knex.Config } = {
development: Connector.parseURL(appConfig.mariadbConnectUrl),
};

module.exports = config;
24 changes: 24 additions & 0 deletions packages/portal/migrations/20230814081635_create_user_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Knex } from 'knex';
import { addCreatedAndUpdated, addIdAndUuid } from '../src/helper/table';

export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable('user', (table: Knex.CreateTableBuilder) => {
addIdAndUuid(knex, table);

table.string('name', 36).notNullable().unique().index();

table.string('activeCode', 32).nullable().index();

table.boolean('isActivated').notNullable().defaultTo(false);

table.dateTime('banUntil').nullable().defaultTo(null);

addCreatedAndUpdated(knex, table);

table.index(['uuid', 'name'], 'indexed_fields');
});
}

export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable('user');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Knex } from 'knex';
import { addCreatedAndUpdated, addIdAndUuid } from '../src/helper/table';

export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable(
'login_method',
(table: Knex.CreateTableBuilder) => {
addIdAndUuid(knex, table);

table
.bigInteger('userId')
.notNullable()
.unsigned()
.references('user.id')
.comment('Foreign key to user.id')
.index();

table.string('type', 10).notNullable().index().comment('Login type');

table.string('externalId', 255).nullable().unique().index();

table.string('email', 255).notNullable().index();

table.string('password', 512).nullable();

addCreatedAndUpdated(knex, table);

table.index(['uuid', 'externalId', 'email', 'userId'], 'indexed_fields');
}
);
}

export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable('login_method');
}
29 changes: 29 additions & 0 deletions packages/portal/migrations/20230814083450_create_profile_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Knex } from 'knex';
import { addCreatedAndUpdated, addIdAndUuid } from '../src/helper/table';

export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable(
'profile',
(table: Knex.CreateTableBuilder) => {
addIdAndUuid(knex, table);

table
.bigInteger('userId')
.notNullable()
.unsigned()
.references('user.id')
.comment('Foreign key to user.id')
.index();

table.string('key', 255).notNullable();

table.string('value', 512).notNullable();

addCreatedAndUpdated(knex, table);
}
);
}

export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable('profile');
}
31 changes: 31 additions & 0 deletions packages/portal/migrations/20230815153731_create_api_key_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Knex } from 'knex';
import { addCreatedAndUpdated, addIdAndUuid } from '../src/helper/table';

export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable(
'api_key',
(table: Knex.CreateTableBuilder) => {
addIdAndUuid(knex, table);

table
.bigInteger('userId')
.notNullable()
.unsigned()
.references('user.id')
.comment('Foreign key to user.id')
.index();

table.string('name', 255).notNullable().index();

table.string('key', 255).notNullable().index();

table.index(['uuid', 'key', 'name'], 'indexed_fields');

addCreatedAndUpdated(knex, table);
}
);
}

export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable('api_key');
}
33 changes: 33 additions & 0 deletions packages/portal/migrations/20230906161520_create_file_log_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Knex } from 'knex';
import { addCreatedAndUpdated, addIdAndUuid } from '../src/helper/table';

export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable(
'file_log',
(table: Knex.CreateTableBuilder) => {
addIdAndUuid(knex, table);

table
.bigInteger('userId')
.notNullable()
.unsigned()
.references('user.id')
.comment('Foreign key to user.id')
.index();

table.string('name', 255).notNullable().index();

table.string('hash', 255).notNullable().index();

table.boolean('isRemoved').notNullable().defaultTo(false);

table.index(['uuid', 'name'], 'indexed_fields');

addCreatedAndUpdated(knex, table);
}
);
}

export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable('file_log');
}
Loading
Loading