Skip to content

Commit

Permalink
Merge pull request #64 from infinitybase/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
guimroque authored Feb 20, 2024
2 parents 4f88f55 + 4b13def commit 50033af
Show file tree
Hide file tree
Showing 108 changed files with 3,989 additions and 1,039 deletions.
36 changes: 25 additions & 11 deletions .env
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
# Database
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=postgres

# App
API_PORT=3333
API_NAME=bsafe-api
API_DOCKERFILE=
API_ENVIRONMENT=development
UI_URL=http://localhost:5175
API_URL=http://localhost:3333

# Database
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 5432
DATABASE_USERNAME = postgres
DATABASE_PASSWORD = postgres
DATABASE_NAME = postgres
# Admin user
APP_ADMIN_EMAIL=admin_user_email
APP_ADMIN_PASSWORD=admin_user_password


DATABASE_PORT_TEST = 5432
# APP
API_PORT=3333
APP_NAME=bsafe-api
# ADMIN USER
APP_ADMIN_EMAIL=admin_user_email
APP_ADMIN_PASSWORD=admin_user_password

# TOKENS
ACCESS_TOKEN_SECRET=access_token_secret
REFRESH_TOKEN_SECRET=refresh_token_secret

# AWS
UI_URL=https://app.bsafe.pro
AWS_SMTP_USER=
AWS_SMTP_PASS=

# EMAIL
EMAIL_FROM="Bsafe <[email protected]>"
MAIL_TESTING_NOTIFICATIONS=[email protected]


44 changes: 29 additions & 15 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
# Database
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 5432
DATABASE_USERNAME = database_username
DATABASE_PASSWORD = database_password
DATABASE_NAME = database_name
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=postgres

# App
API_PORT = 3333
API_PORT=3333
API_NAME=bsafe-api
API_DOCKERFILE=
API_ENVIRONMENT=development
UI_URL=http://localhost:5175
API_URL=http://localhost:3333

# Admin user
APP_ADMIN_EMAIL = admin_user_email
APP_ADMIN_PASSWORD = admin_user_password
APP_ADMIN_EMAIL=admin_user_email
APP_ADMIN_PASSWORD=admin_user_password

# Tokens
ACCESS_TOKEN_SECRET = access_token_secret
REFRESH_TOKEN_SECRET = refresh_token_secret
TOKEN_EXPIRTATION_TIME = 15

# ADMIN USER
APP_ADMIN_EMAIL=admin_user_email
APP_ADMIN_PASSWORD=admin_user_password

# TOKENS
ACCESS_TOKEN_SECRET=access_token_secret
REFRESH_TOKEN_SECRET=refresh_token_secret

# AWS
AWS_SMTP_USER=
AWS_SMTP_PASS=

# EMAIL
EMAIL_FROM="Bsafe <[email protected]>"
MAIL_TESTING_NOTIFICATIONS=[email protected]


#UI
UI_URL=http://localhost:5175
#UI_URL=https://app.bsafe.pro
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ yarn.lock
package-lock.json
.editorconfig
bsafe/

#env
.env
.env.staging
.env.prod

# Mac OS
.DS_Store
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
prod:
sudo docker-compose -f docker-compose.yml --env-file ${env_file} up --build -d

stg:
sudo docker-compose -f docker-compose.yml --env-file ${env_file} up --build -d

34 changes: 0 additions & 34 deletions docker-compose.prod.yml

This file was deleted.

32 changes: 0 additions & 32 deletions docker-compose.stg.yml

This file was deleted.

37 changes: 37 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3'
services:
api:
container_name: ${API_NAME}
ports:
- '${API_PORT}:${API_PORT}'
build:
dockerfile: ${API_DOCKERFILE}
context: .
working_dir: /api
volumes:
- ./uploads:/api/uploads
environment:
- NODE_ENV=${API_ENVIRONMENT}
# DATABASE
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_PORT=${DATABASE_PORT}
- DATABASE_USERNAME=${DATABASE_USERNAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_NAME=${DATABASE_NAME}
# APP
- API_PORT=${API_PORT}
- APP_NAME=${API_NAME}
# ADMIN USER
- APP_ADMIN_EMAIL=${APP_ADMIN_EMAIL}
- APP_ADMIN_PASSWORD=${APP_ADMIN_PASSWORD}
# TOKENS
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
- REFRESH_TOKEN_SECRET=${REFRESH_TOKEN_SECRET}
# AWS
- UI_URL=${UI_URL}
- API_URL=${API_URL}
- AWS_SMTP_USER=${AWS_SMTP_USER}
- AWS_SMTP_PASS=${AWS_SMTP_PASS}
# EMAIL
- EMAIL_FROM=${EMAIL_FROM}
- MAIL_TESTING_NOTIFICATIONS=${MAIL_TESTING_NOTIFICATIONS}
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: JestConfigWithTsJest = {
'^@utils/(.*)$': '<rootDir>/src/utils/$1',
'^@mocks/(.*)$': '<rootDir>/src/mocks/$1',
},
testPathIgnorePatterns: ['/node_modules/', '/build/'],
};

export default config;
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"test": "chmod +x ./scripts/init_test.sh && ./scripts/init_test.sh",
"start": "pm2-runtime start ./build/server/index.js",
"build": "tsc --project . && tscpaths -p tsconfig.json -s ./src -o ./build",
"copyFiles": "copyfiles --error --up 1 src/**/*.html build",
"postbuild": "yarn run copyFiles",
"migration:run": "ts-node -r tsconfig-paths/register -r dotenv/config ./node_modules/typeorm/cli.js migration:run",
"migration:create": "ts-node -r tsconfig-paths/register -r dotenv/config ./node_modules/typeorm/cli.js migration:create -n",
"migration:revert": "ts-node -r tsconfig-paths/register -r dotenv/config ./node_modules/typeorm/cli.js migration:revert",
Expand All @@ -16,15 +18,19 @@
"database:dev": "make -C ./docker/database start env_file=.env.dev",
"database:stop": "make -C ./docker/database start",
"database:start": "make -C ./docker/database start",
"postinstall": "patch-package --use-yarn"
"postinstall": "patch-package --use-yarn",
"run:prod": "make -C ./ prod env_file=.env.prod",
"run:stg": "make -C ./ stg env_file=.env.staging"
},
"dependencies": {
"axios": "1.5.1",
"bcrypt": "5.1.0",
"body-parser": "1.20.2",
"bsafe": "0.0.35",
"cheerio": "1.0.0-rc.12",
"class-validator": "0.14.0",
"cookie-parser": "1.4.6",
"copyfiles": "2.4.1",
"cors": "2.8.5",
"date-fns": "2.30.0",
"dotenv": "8.2.0",
Expand All @@ -33,6 +39,7 @@
"joi": "17.4.0",
"jsonwebtoken": "9.0.1",
"morgan": "1.10.0",
"nodemailer": "6.9.8",
"patch-package": "8.0.0",
"pg": "8.5.1",
"pm2": "5.3.0",
Expand Down
1 change: 0 additions & 1 deletion src/config/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const {
DATABASE_NAME,
DATABASE_PORT,
NODE_ENV,
DATABASE_PORT_TEST,
} = process.env;

const [host, port] = String(DATABASE_URL).split(':');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class addTableVaultTemplate1696881120692 implements MigrationInterface {
isNullable: true,
},
{
name: 'min_signers',
name: 'minSigners',
type: 'integer',
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

export class addNotificationsColumnsToUsersTable1702391257625
implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.addColumns('users', [
new TableColumn({
name: 'first_login',
type: 'boolean',
default: true,
}),
new TableColumn({
name: 'notify',
type: 'boolean',
default: false,
}),
]);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumns('users', ['first_login', 'notify']);
}
}
72 changes: 72 additions & 0 deletions src/database/migrations/1703070591761-create-table-workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class createTableWorkspace1703070591761 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'workspace',
columns: [
{
name: 'id',
type: 'uuid',
isPrimary: true,
isUnique: true,
generationStrategy: 'uuid',
default: `uuid_generate_v4()`,
},
{
name: 'name',
type: 'varchar',
isNullable: false,
},
{
name: 'description',
type: 'text',
isNullable: true,
},
{
name: 'permissions',
type: 'json',
isNullable: false,
},
{
name: 'avatar',
type: 'varchar',
isNullable: true,
},
{
name: 'owner_id',
type: 'uuid',
isNullable: false,
},
{
name: 'created_at',
type: 'timestamp',
},
{
name: 'updated_at',
type: 'timestamp',
isNullable: true,
},
{
name: 'deleted_at',
type: 'timestamp',
isNullable: true,
},
],
foreignKeys: [
{
columnNames: ['owner_id'],
referencedColumnNames: ['id'],
referencedTableName: 'users',
onDelete: 'CASCADE',
},
],
}),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('workspace');
}
}
Loading

0 comments on commit 50033af

Please sign in to comment.