Skip to content

Commit

Permalink
V2 (#25)
Browse files Browse the repository at this point in the history
* V2: change the way to create routes

* Make new api easier to use

* Fix build

* Fix build

* Add swagger support

* Update docs/pages/api-docs/adapters.mdx

Co-authored-by: Thibault Lenclos <tlenclos@users.noreply.github.com>

* Update docs/pages/api-docs/callbacks.mdx

Co-authored-by: Thibault Lenclos <tlenclos@users.noreply.github.com>

* Add doc + add swagger-typescript-api

Co-authored-by: Thibault Lenclos <tlenclos@users.noreply.github.com>
  • Loading branch information
foyarash and tlenclos authored Oct 4, 2021
1 parent 866834f commit f7b5ca0
Show file tree
Hide file tree
Showing 36 changed files with 4,329 additions and 2,857 deletions.
25 changes: 17 additions & 8 deletions __tests__/adapters/prisma/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getMockReq, getMockRes } from '@jest-mock/express'
import NextCrud from '../../../src/handler'
import PrismaAdapter from '../../../src/adapters/prisma'
import { User } from '@prisma/client'
import { User, Post, Prisma } from '@prisma/client'
import prisma from './client'
import { NextApiHandler } from 'next'
import { createSeedData } from './seed'
Expand All @@ -10,18 +10,27 @@ describe('Prisma interraction', () => {
beforeAll(async () => {
await createSeedData()
})
let adapter: PrismaAdapter<User>
let handler: NextApiHandler<User>
let adapter: PrismaAdapter<User | Post, Prisma.ModelName>
let handler: NextApiHandler<User | Post>

beforeEach(() => {
adapter = new PrismaAdapter<User>({
modelName: 'user',
manyRelations: ['post.author', 'comment.post', 'comment.author'],
adapter = new PrismaAdapter<User | Post, Prisma.ModelName>({
prismaClient: prisma,
manyRelations: {
[Prisma.ModelName.User]: [
'post.author',
'comment.post',
'comment.author',
],
},
})

handler = NextCrud({
adapter,
resourceName: 'users',
models: {
[Prisma.ModelName.User]: {
name: 'users',
},
},
})
})

Expand Down
Loading

0 comments on commit f7b5ca0

Please sign in to comment.