-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add overall improvements and minor bugs fixes (#11)
* feat: add reenableClaim mutation * feat: notify newly added claim attributions * chore: remove unused vars * feat: notify newly added knowledge bit attributions * feat: require email confirmation on email update * feat: replace magic link by sign in code * feat: add claimsByTag query * feat: save tweet hashtags as FF tags * feat: add database migrations * feat: send all matching entries on tags search * chore: remove generate-typings function
- Loading branch information
1 parent
9b9d3f0
commit fed1616
Showing
29 changed files
with
604 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { TypeOrmModuleOptions } from '@nestjs/typeorm'; | ||
import fs from 'fs'; | ||
import { join } from 'path'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
const ormConfig: TypeOrmModuleOptions = { | ||
type: 'postgres', | ||
host: process.env.POSTGRES_HOST, | ||
port: Number(process.env.POSTGRES_PORT), | ||
username: process.env.POSTGRES_USERNAME, | ||
password: process.env.POSTGRES_PASSWORD, | ||
database: process.env.POSTGRES_DATABASE, | ||
entities: [process.env.POSTGRES_ENTITIES], | ||
synchronize: process.env.POSTGRES_SYNCHRONIZE === 'true', | ||
logging: process.env.POSTGRES_LOGGING === 'true', | ||
migrations: [process.env.POSTGRES_MIGRATIONS], | ||
migrationsTableName: process.env.POSTGRES_MIGRATIONS_TABLE_NAME, | ||
migrationsRun: process.env.POSTGRES_MIGRATIONS_RUN === 'true', | ||
ssl: { | ||
rejectUnauthorized: true, | ||
ca: fs | ||
.readFileSync(join(process.cwd(), 'certs/ca-certificate.crt')) | ||
.toString(), | ||
}, | ||
cli: { | ||
migrationsDir: './src/migrations', | ||
}, | ||
}; | ||
|
||
export default ormConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import slugify from 'slugify'; | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
import { Tag } from 'src/modules/tags/entities/tag.entity'; | ||
|
||
export class tagSlug1643311787893 implements MigrationInterface { | ||
name = 'tagSlug1643311787893'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "magicLinkHash"`); | ||
await queryRunner.query( | ||
`ALTER TABLE "tag" ADD "slug" character varying NOT NULL DEFAULT 'x'`, | ||
); | ||
|
||
await queryRunner.startTransaction(); | ||
const tags = await queryRunner.manager.find(Tag); | ||
const updatedTags = tags.reduce((acc, curr) => { | ||
const baseSlug = slugify(curr.label, { | ||
lower: true, | ||
strict: true, | ||
}); | ||
let slug; | ||
let slugIndex = 0; | ||
|
||
do { | ||
slug = `${baseSlug}${slugIndex > 0 ? `-${slugIndex}` : ''}`; | ||
slugIndex++; | ||
} while ( | ||
tags.find((tag) => tag.slug === slug) !== undefined || | ||
acc.find((tag) => tag.slug === slug) !== undefined | ||
); | ||
|
||
const tag = queryRunner.manager.create(Tag, { ...curr, slug }); | ||
|
||
return [...acc, tag]; | ||
}, []); | ||
|
||
await queryRunner.manager.save(updatedTags); | ||
await queryRunner.commitTransaction(); | ||
|
||
await queryRunner.query( | ||
`ALTER TABLE "tag" ADD CONSTRAINT "UQ_3413aed3ecde54f832c4f44f045" UNIQUE ("slug")`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "tag" DROP CONSTRAINT "UQ_3413aed3ecde54f832c4f44f045"`, | ||
); | ||
await queryRunner.query(`ALTER TABLE "tag" DROP COLUMN "slug"`); | ||
await queryRunner.query( | ||
`ALTER TABLE "user" ADD "magicLinkHash" character varying`, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.