Skip to content

Commit

Permalink
Update configuration and remove unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcrammer committed Mar 25, 2024
1 parent 3c10767 commit a508db4
Show file tree
Hide file tree
Showing 53 changed files with 3,941 additions and 757 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"targets": {
"node": "current"
}
}
},
"@babel/preset-typescript"
]
],
"plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-object-rest-spread"]
Expand Down
Empty file removed .dockerignore
Empty file.
33 changes: 33 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: "airbnb-base",
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
"no-console": 1,
"class-methods-use-this": 0,
"comma-dangle": 0,
"max-len": 0,
"object-curly-newline": 0,
"consistent-return": 0,
"prefer-const": 0,
quotes: ["error", "double"],
semi: ["error", "never"],
},
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ web_modules/
.env.test.local
.env.production.local
.env.local
.env.secrets

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down Expand Up @@ -127,4 +128,7 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*

# Keys
*.pem
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"tabWidth": 2,
"trailingComma": "es5",
"tailwindcss": {},
"printWidth": 120
"printWidth": 140
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["github.copilot-chat"]
}
5 changes: 3 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require("dotenv").config()
import "dotenv/config"

module.exports = {
const config = {
development: {
username: process.env.DEV_DB_USER,
password: process.env.DEV_DB_PASS,
Expand All @@ -26,3 +26,4 @@ module.exports = {
dialect: "mysql",
},
}
export default config
3 changes: 2 additions & 1 deletion src/database/database.js → config/database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "dotenv/config"
import { Sequelize } from "sequelize"
import config from "../../config/config"
import config from "./config"

const nodeEnv = process.env.NODE_ENV || "development"
const { username: user, password, database: db, host, port } = config[nodeEnv]
Expand Down
34 changes: 0 additions & 34 deletions migrations/20231204041655-convert-role-field-to-name.js

This file was deleted.

47 changes: 0 additions & 47 deletions migrations/20231204042130-edit-role.js

This file was deleted.

20 changes: 0 additions & 20 deletions migrations/20231204051733-add-inherit-caps-field.js

This file was deleted.

14 changes: 0 additions & 14 deletions migrations/20231204055326-add-baseCategory-field.js

This file was deleted.

25 changes: 25 additions & 0 deletions migrations/20240116230803-convert-user-id-to-uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable lines-around-directive */
/* eslint-disable strict */
/* eslint-disable no-unused-vars */
"use strict"

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.changeColumn("Users", "id", {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
allowNull: false,
primaryKey: true,
})
},

async down(queryInterface, Sequelize) {
await queryInterface.changeColumn("Users", "id", {
type: Sequelize.INTEGER,
allowNull: false,
autoIncrement: true,
primaryKey: true,
})
},
}
30 changes: 30 additions & 0 deletions models/AuthFactor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { DataTypes } from "sequelize"
import sequelize from "../config/database"

// storing information used in 2-factor authentication (2FA)
const AuthFactor = sequelize.define("AuthFactor", {
id: {
type: DataTypes.UUID,
primaryKey: true,
defaultValue: DataTypes.UUIDV4,
},
factor: {
type: DataTypes.STRING,
allowNull: false,
},
secret: {
type: DataTypes.STRING,
allowNull: false,
},
verified: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
verifiedAt: {
type: DataTypes.DATE,
allowNull: true,
},
})

export default AuthFactor
21 changes: 21 additions & 0 deletions models/Capability.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DataTypes } from "sequelize"
import sequelize from "../config/database"

const Capability = sequelize.define("Capability", {
id: {
type: DataTypes.INTEGER, // or DataTypes.UUID
primaryKey: true,
autoIncrement: true, // set to false if using UUID
},
name: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
},
description: {
type: DataTypes.STRING,
allowNull: true,
},
})

export default Capability
32 changes: 32 additions & 0 deletions models/Role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { DataTypes } from "sequelize"
import sequelize from "../config/database"

const Role = sequelize.define(
"Role",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
},
description: {
type: DataTypes.STRING,
allowNull: true,
},
},
{
indexes: [
{
unique: true,
fields: ["name"],
},
],
}
)

export default Role
12 changes: 12 additions & 0 deletions models/Role_Capability.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DataTypes } from "sequelize"
import sequelize from "../config/database"

const RoleCapability = sequelize.define("Role_Capability", {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
})

export default RoleCapability
25 changes: 25 additions & 0 deletions models/Token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { DataTypes } from "sequelize"
import sequelize from "../config/database"

const Token = sequelize.define("Token", {
id: {
type: DataTypes.UUID,
primaryKey: true,
defaultValue: DataTypes.UUIDV4,
},
token: {
type: DataTypes.STRING(1000),
allowNull: false,
},
expires: {
type: DataTypes.DATE,
allowNull: false,
},
blacklisted: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
})

export default Token
Loading

0 comments on commit a508db4

Please sign in to comment.