-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: poc twitter * feat: create url * feat: oauth twitter * feat: migrations * feat: oauth2 twitter * refactor: remove deprecated twitter-api-sdk package and unused code * refactor: remove deprecated twitter-api-sdk package and unused code * feat: implements suite cases * Delete tasks.md * test: fix broken jwt middleware * fix: factory * feat: add null to return accounts * fix: lint, errors --------- Co-authored-by: k1nha <[email protected]>
- Loading branch information
Showing
43 changed files
with
905 additions
and
113 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
prisma/migrations/20240719232325_add_new_columns_in_account/migration.sql
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,14 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `avatarUrl` on the `accounts` table. All the data in the column will be lost. | ||
- Added the required column `avatar_url` to the `accounts` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "accounts" DROP COLUMN "avatarUrl", | ||
ADD COLUMN "avatar_url" TEXT NOT NULL, | ||
ADD COLUMN "name" TEXT, | ||
ADD COLUMN "social_user_id" TEXT, | ||
ADD COLUMN "username" TEXT, | ||
ALTER COLUMN "updated_at" DROP DEFAULT; |
23 changes: 23 additions & 0 deletions
23
prisma/migrations/20240722010704_rename_columns/migration.sql
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,23 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `social_user_id` on the `accounts` table. All the data in the column will be lost. | ||
- Added the required column `favorite` to the `accounts` table without a default value. This is not possible if the table is not empty. | ||
- Made the column `social_media_id` on table `accounts` required. This step will fail if there are existing NULL values in that column. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "accounts" DROP CONSTRAINT "accounts_social_media_id_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "accounts" DROP COLUMN "social_user_id", | ||
ADD COLUMN "favorite" BOOLEAN NOT NULL, | ||
ADD COLUMN "social_media_user_id" TEXT, | ||
ALTER COLUMN "social_media_id" SET NOT NULL, | ||
ALTER COLUMN "avatar_url" DROP NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "social_media" ALTER COLUMN "description" DROP NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_social_media_id_fkey" FOREIGN KEY ("social_media_id") REFERENCES "social_media"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
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,32 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
await prisma.socialMedia.createMany({ | ||
data: [ | ||
{ | ||
description: '', | ||
name: 'Twitter', | ||
}, | ||
{ | ||
description: '', | ||
name: 'Instagram', | ||
}, | ||
{ | ||
description: '', | ||
name: 'Facebook', | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log('Seed executed'); | ||
prisma.$disconnect(); | ||
process.exit(0); | ||
}) | ||
.finally(() => { | ||
prisma.$disconnect(); | ||
}); |
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
51 changes: 51 additions & 0 deletions
51
src/features/account/repositories/token-repository/token-repository.test.ts
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,51 @@ | ||
import { faker } from '@faker-js/faker/locale/pt_BR'; | ||
import { prisma } from 'mocks/prisma'; | ||
|
||
import { TokenRepository } from './token-repository'; | ||
|
||
describe('[Repositories] TokenRepository', () => { | ||
let sut: TokenRepository; | ||
|
||
beforeEach(() => { | ||
sut = new TokenRepository(); | ||
}); | ||
|
||
it('upsert', async () => { | ||
const input = { | ||
accessToken: faker.string.alpha(), | ||
accountId: faker.string.alpha(), | ||
authToken: faker.string.alpha(), | ||
expiresIn: faker.number.int({ max: 100 }), | ||
}; | ||
|
||
const expected = { | ||
accountId: faker.string.alpha(), | ||
authToken: faker.string.alpha(), | ||
expiresIn: faker.number.int({ max: 100 }), | ||
id: faker.number.int({ max: 100 }), | ||
issuedAt: new Date(), | ||
token: faker.string.alpha(), | ||
}; | ||
|
||
prisma.token.upsert.mockResolvedValue(expected); | ||
|
||
const result = await sut.upsert(input); | ||
|
||
expect(result).toEqual(expected); | ||
expect(prisma.token.upsert).toHaveBeenCalledWith({ | ||
create: { | ||
authToken: input.authToken, | ||
expiresIn: input.expiresIn, | ||
issuedAt: expect.any(Date), | ||
token: input.accessToken, | ||
}, | ||
update: { | ||
expiresIn: input.expiresIn, | ||
token: input.accessToken, | ||
}, | ||
where: { | ||
accountId: input.accountId, | ||
}, | ||
}); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
src/features/account/repositories/token-repository/token-repository.ts
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,22 @@ | ||
import type { UpsertParams } from '@/features/account/models/account-model'; | ||
import { database } from '@/shared/infra/database/database'; | ||
|
||
export class TokenRepository { | ||
upsert({ accessToken, accountId, authToken, expiresIn }: UpsertParams) { | ||
return database.token.upsert({ | ||
create: { | ||
authToken, | ||
expiresIn, | ||
issuedAt: new Date(), | ||
token: accessToken, | ||
}, | ||
update: { | ||
expiresIn, | ||
token: accessToken, | ||
}, | ||
where: { | ||
accountId, | ||
}, | ||
}); | ||
} | ||
} |
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
7 changes: 1 addition & 6 deletions
7
src/features/auth/repositories/auth-repository/auth-repository.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export type SocialMediaModel = { | ||
description: string; | ||
description: null | string; | ||
id: number; | ||
name: string; | ||
}; |
Oops, something went wrong.