create-cedar-app 7.0.0 → 7.0.1-next.305
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/database-overlays/neon-postgres/api/package.json +3 -3
- package/database-overlays/pglite/api/package.json +3 -3
- package/dist/create-cedar-app.js +366 -368
- package/package.json +5 -7
- package/templates/js/api/jsconfig.json +2 -2
- package/templates/js/api/package.json +12 -6
- package/templates/js/api/src/directives/requireAuth/requireAuth.js +1 -1
- package/templates/js/api/src/directives/skipAuth/skipAuth.js +1 -1
- package/templates/js/api/src/lib/auth.js +2 -2
- package/templates/js/api/src/lib/db.js +3 -1
- package/templates/js/package.json +12 -7
- package/templates/js/scripts/jsconfig.json +1 -2
- package/templates/js/web/jsconfig.json +1 -2
- package/templates/js/web/package.json +13 -9
- package/templates/js/web/src/pages/FatalErrorPage/FatalErrorPage.jsx +0 -1
- package/templates/js/web/src/pages/NotFoundPage/NotFoundPage.jsx +0 -1
- package/templates/js/web/vite.config.js +11 -3
- package/templates/overlays/{esm/npm → npm}/package.json +8 -8
- package/templates/overlays/{esm/pnpm → pnpm}/package.json +7 -7
- package/templates/overlays/{esm/pnpm → pnpm}/pnpm-workspace.yaml +1 -1
- package/templates/overlays/{esm/yarn → yarn}/package.json +8 -8
- package/templates/ts/api/package.json +12 -6
- package/templates/ts/api/src/directives/requireAuth/requireAuth.ts +1 -1
- package/templates/ts/api/src/directives/skipAuth/skipAuth.ts +1 -1
- package/templates/ts/api/src/lib/auth.ts +2 -2
- package/templates/ts/api/src/lib/db.ts +3 -1
- package/templates/ts/api/tsconfig.json +1 -0
- package/templates/ts/eslint.config.js +11 -0
- package/templates/ts/package.json +12 -7
- package/templates/ts/scripts/tsconfig.json +0 -1
- package/templates/ts/web/package.json +13 -9
- package/templates/ts/web/vite.config.ts +11 -3
- package/templates/esm-js/.cedar/README.md +0 -44
- package/templates/esm-js/.editorconfig +0 -10
- package/templates/esm-js/.env +0 -15
- package/templates/esm-js/.env.defaults +0 -19
- package/templates/esm-js/.env.example +0 -4
- package/templates/esm-js/.vscode/extensions.json +0 -14
- package/templates/esm-js/.vscode/launch.json +0 -56
- package/templates/esm-js/.vscode/settings.json +0 -11
- package/templates/esm-js/.vscode/tasks.json +0 -29
- package/templates/esm-js/README.md +0 -17
- package/templates/esm-js/api/db/schema.prisma +0 -29
- package/templates/esm-js/api/jsconfig.json +0 -41
- package/templates/esm-js/api/package.json +0 -19
- package/templates/esm-js/api/prisma.config.cjs +0 -12
- package/templates/esm-js/api/src/directives/requireAuth/requireAuth.js +0 -22
- package/templates/esm-js/api/src/directives/requireAuth/requireAuth.test.js +0 -18
- package/templates/esm-js/api/src/directives/skipAuth/skipAuth.js +0 -16
- package/templates/esm-js/api/src/directives/skipAuth/skipAuth.test.js +0 -10
- package/templates/esm-js/api/src/functions/graphql.js +0 -19
- package/templates/esm-js/api/src/graphql/.keep +0 -0
- package/templates/esm-js/api/src/lib/auth.js +0 -32
- package/templates/esm-js/api/src/lib/db.js +0 -46
- package/templates/esm-js/api/src/lib/logger.js +0 -17
- package/templates/esm-js/api/src/services/.keep +0 -0
- package/templates/esm-js/cedar.toml +0 -26
- package/templates/esm-js/gitignore.template +0 -27
- package/templates/esm-js/graphql.config.cjs +0 -11
- package/templates/esm-js/package.json +0 -33
- package/templates/esm-js/prettier.config.cjs +0 -18
- package/templates/esm-js/scripts/.keep +0 -0
- package/templates/esm-js/scripts/jsconfig.json +0 -60
- package/templates/esm-js/scripts/seed.js +0 -27
- package/templates/esm-js/web/index.html +0 -15
- package/templates/esm-js/web/jsconfig.json +0 -53
- package/templates/esm-js/web/package.json +0 -30
- package/templates/esm-js/web/public/README.md +0 -43
- package/templates/esm-js/web/public/favicon.png +0 -0
- package/templates/esm-js/web/public/robots.txt +0 -2
- package/templates/esm-js/web/src/App.jsx +0 -16
- package/templates/esm-js/web/src/Routes.jsx +0 -20
- package/templates/esm-js/web/src/components/.keep +0 -0
- package/templates/esm-js/web/src/entry.client.jsx +0 -35
- package/templates/esm-js/web/src/index.css +0 -0
- package/templates/esm-js/web/src/layouts/.keep +0 -0
- package/templates/esm-js/web/src/pages/FatalErrorPage/FatalErrorPage.jsx +0 -58
- package/templates/esm-js/web/src/pages/NotFoundPage/NotFoundPage.jsx +0 -45
- package/templates/esm-js/web/vite.config.js +0 -15
- package/templates/esm-ts/.cedar/README.md +0 -44
- package/templates/esm-ts/.editorconfig +0 -10
- package/templates/esm-ts/.env +0 -15
- package/templates/esm-ts/.env.defaults +0 -19
- package/templates/esm-ts/.env.example +0 -4
- package/templates/esm-ts/.vscode/extensions.json +0 -14
- package/templates/esm-ts/.vscode/launch.json +0 -56
- package/templates/esm-ts/.vscode/settings.json +0 -11
- package/templates/esm-ts/.vscode/tasks.json +0 -29
- package/templates/esm-ts/README.md +0 -17
- package/templates/esm-ts/api/db/schema.prisma +0 -29
- package/templates/esm-ts/api/package.json +0 -19
- package/templates/esm-ts/api/prisma.config.cjs +0 -12
- package/templates/esm-ts/api/src/directives/requireAuth/requireAuth.test.ts +0 -18
- package/templates/esm-ts/api/src/directives/requireAuth/requireAuth.ts +0 -25
- package/templates/esm-ts/api/src/directives/skipAuth/skipAuth.test.ts +0 -10
- package/templates/esm-ts/api/src/directives/skipAuth/skipAuth.ts +0 -16
- package/templates/esm-ts/api/src/functions/graphql.ts +0 -19
- package/templates/esm-ts/api/src/graphql/.keep +0 -0
- package/templates/esm-ts/api/src/lib/auth.ts +0 -32
- package/templates/esm-ts/api/src/lib/db.ts +0 -46
- package/templates/esm-ts/api/src/lib/logger.ts +0 -17
- package/templates/esm-ts/api/src/services/.keep +0 -0
- package/templates/esm-ts/api/tsconfig.json +0 -27
- package/templates/esm-ts/cedar.toml +0 -26
- package/templates/esm-ts/eslint.config.js +0 -3
- package/templates/esm-ts/gitignore.template +0 -27
- package/templates/esm-ts/graphql.config.cjs +0 -11
- package/templates/esm-ts/package.json +0 -33
- package/templates/esm-ts/prettier.config.cjs +0 -18
- package/templates/esm-ts/scripts/.keep +0 -0
- package/templates/esm-ts/scripts/seed.ts +0 -27
- package/templates/esm-ts/scripts/tsconfig.json +0 -35
- package/templates/esm-ts/web/index.html +0 -15
- package/templates/esm-ts/web/package.json +0 -30
- package/templates/esm-ts/web/public/README.md +0 -43
- package/templates/esm-ts/web/public/favicon.png +0 -0
- package/templates/esm-ts/web/public/robots.txt +0 -2
- package/templates/esm-ts/web/src/App.tsx +0 -22
- package/templates/esm-ts/web/src/Routes.tsx +0 -20
- package/templates/esm-ts/web/src/components/.keep +0 -0
- package/templates/esm-ts/web/src/entry.client.tsx +0 -35
- package/templates/esm-ts/web/src/index.css +0 -0
- package/templates/esm-ts/web/src/layouts/.keep +0 -0
- package/templates/esm-ts/web/src/pages/FatalErrorPage/FatalErrorPage.tsx +0 -57
- package/templates/esm-ts/web/src/pages/NotFoundPage/NotFoundPage.tsx +0 -44
- package/templates/esm-ts/web/tsconfig.json +0 -45
- package/templates/esm-ts/web/vite.config.ts +0 -15
- package/templates/js/api/jest.config.js +0 -8
- package/templates/js/eslint.config.mjs +0 -3
- package/templates/js/jest.config.js +0 -8
- package/templates/js/web/jest.config.js +0 -8
- package/templates/overlays/cjs/npm/package-lock.json +0 -28868
- package/templates/overlays/cjs/npm/package.json +0 -31
- package/templates/overlays/cjs/pnpm/package.json +0 -32
- package/templates/overlays/cjs/pnpm/pnpm-lock.yaml +0 -18204
- package/templates/overlays/cjs/pnpm/pnpm-workspace.yaml +0 -23
- package/templates/overlays/cjs/yarn/package.json +0 -73
- package/templates/overlays/cjs/yarn/yarn.lock +0 -18896
- package/templates/overlays/esm/npm/package-lock.json +0 -29256
- package/templates/overlays/esm/pnpm/pnpm-lock.yaml +0 -18683
- package/templates/overlays/esm/yarn/.yarnrc.yml +0 -17
- package/templates/overlays/esm/yarn/yarn.lock +0 -19181
- package/templates/ts/api/jest.config.js +0 -8
- package/templates/ts/eslint.config.mjs +0 -3
- package/templates/ts/jest.config.js +0 -8
- package/templates/ts/web/jest.config.js +0 -8
- /package/templates/{esm-js → js}/api/vitest.config.js +0 -0
- /package/templates/{esm-js → js}/eslint.config.js +0 -0
- /package/templates/{esm-js → js}/vitest.config.mjs +0 -0
- /package/templates/{esm-js → js}/web/vitest.setup.js +0 -0
- /package/templates/overlays/{cjs/yarn → yarn}/.yarnrc.yml +0 -0
- /package/templates/{esm-ts → ts}/api/vitest.config.ts +0 -0
- /package/templates/{esm-ts → ts}/vitest.config.ts +0 -0
- /package/templates/{esm-ts → ts}/web/vitest.setup.ts +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"recommendations": [
|
|
3
|
-
"dbaeumer.vscode-eslint",
|
|
4
|
-
"eamodio.gitlens",
|
|
5
|
-
"ofhumanbondage.react-proptypes-intellisense",
|
|
6
|
-
"mgmcdermott.vscode-language-babel",
|
|
7
|
-
"wix.vscode-import-cost",
|
|
8
|
-
"pflannery.vscode-versionlens",
|
|
9
|
-
"editorconfig.editorconfig",
|
|
10
|
-
"prisma.prisma",
|
|
11
|
-
"graphql.vscode-graphql"
|
|
12
|
-
],
|
|
13
|
-
"unwantedRecommendations": []
|
|
14
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.3.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"command": "{{CEDAR_CLI}} dev --apiDebugPort 18911", // you can add --fwd='--open=false' to prevent the browser from opening
|
|
6
|
-
"name": "Run Dev Server",
|
|
7
|
-
"request": "launch",
|
|
8
|
-
"type": "node-terminal"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "Attach API debugger",
|
|
12
|
-
"port": 18911, // you can change this port, see https://cedarjs.com/docs/project-configuration-dev-test-build#debugger-configuration
|
|
13
|
-
"request": "attach",
|
|
14
|
-
"skipFiles": [
|
|
15
|
-
"<node_internals>/**"
|
|
16
|
-
],
|
|
17
|
-
"type": "node",
|
|
18
|
-
"localRoot": "${workspaceFolder}/node_modules/@cedarjs/api-server/dist",
|
|
19
|
-
"remoteRoot": "${workspaceFolder}/node_modules/@cedarjs/api-server/dist",
|
|
20
|
-
"sourceMaps": true,
|
|
21
|
-
"restart": true,
|
|
22
|
-
"preLaunchTask": "WaitForDevServer",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "Launch Web debugger",
|
|
26
|
-
"type": "chrome",
|
|
27
|
-
"request": "launch",
|
|
28
|
-
"url": "http://localhost:8910",
|
|
29
|
-
"webRoot": "${workspaceRoot}/web/src",
|
|
30
|
-
"preLaunchTask": "WaitForDevServer",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"command": "{{CEDAR_CLI}} test api",
|
|
34
|
-
"name": "Test api",
|
|
35
|
-
"request": "launch",
|
|
36
|
-
"type": "node-terminal"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"command": "{{CEDAR_CLI}} test web",
|
|
40
|
-
"name": "Test web",
|
|
41
|
-
"request": "launch",
|
|
42
|
-
"type": "node-terminal"
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
"compounds": [
|
|
46
|
-
{
|
|
47
|
-
"name": "Start Debug",
|
|
48
|
-
"configurations": [
|
|
49
|
-
"Run Dev Server",
|
|
50
|
-
"Attach API debugger",
|
|
51
|
-
"Launch Web debugger"
|
|
52
|
-
],
|
|
53
|
-
"stopAll": true
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "2.0.0",
|
|
3
|
-
"tasks": [
|
|
4
|
-
{
|
|
5
|
-
"label": "WaitForDevServer",
|
|
6
|
-
"group": "none",
|
|
7
|
-
"type": "shell",
|
|
8
|
-
"command": "bash",
|
|
9
|
-
"args": [
|
|
10
|
-
"-c",
|
|
11
|
-
"while ! echo -n > /dev/tcp/localhost/18911; do sleep 1; done;"
|
|
12
|
-
],
|
|
13
|
-
"windows": {
|
|
14
|
-
"command": "powershell",
|
|
15
|
-
"args": [
|
|
16
|
-
"-NoProfile",
|
|
17
|
-
"-ExecutionPolicy", "Bypass",
|
|
18
|
-
"while (-not (Test-NetConnection -ComputerName localhost -Port 18911)) { Start-Sleep -Seconds 1 };"
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
"presentation": {
|
|
22
|
-
"reveal": "silent",
|
|
23
|
-
"revealProblems": "onProblem",
|
|
24
|
-
"panel": "shared",
|
|
25
|
-
"close": true
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
]
|
|
29
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# README
|
|
2
|
-
|
|
3
|
-
Welcome to your new [CedarJS](https://cedarjs.com) project!
|
|
4
|
-
|
|
5
|
-
Start by installing dependencies:
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
{{PM_INSTALL}}
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Then start the development server:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
{{CEDAR_CLI}} dev
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Your browser should automatically open to [http://localhost:8910](http://localhost:8910) where you'll see the Welcome Page, which links out to many great resources.
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Don't forget to tell Prisma about your edits to this file using
|
|
2
|
-
// `yarn cedar prisma migrate dev` or `yarn cedar prisma db push`.
|
|
3
|
-
// `migrate` is like committing while `push` is for prototyping.
|
|
4
|
-
// Read more about both here:
|
|
5
|
-
// https://www.prisma.io/docs/orm/prisma-migrate
|
|
6
|
-
|
|
7
|
-
datasource db {
|
|
8
|
-
provider = "sqlite"
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// This specific combination of settings is the only way to make Prisma 7 work
|
|
12
|
-
// in both CJS and ESM Cedar apps.
|
|
13
|
-
// See https://github.com/cedarjs/cedar/pull/1761 for more info
|
|
14
|
-
generator client {
|
|
15
|
-
provider = "prisma-client"
|
|
16
|
-
output = "./generated/prisma"
|
|
17
|
-
moduleFormat = "cjs"
|
|
18
|
-
generatedFileExtension = "mts"
|
|
19
|
-
importFileExtension = "mts"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Define your own datamodels here and run `yarn cedar prisma migrate dev`
|
|
23
|
-
// to create migrations for them and apply to your dev DB.
|
|
24
|
-
// TODO: Please remove the following example:
|
|
25
|
-
model UserExample {
|
|
26
|
-
id Int @id @default(autoincrement())
|
|
27
|
-
email String @unique
|
|
28
|
-
name String?
|
|
29
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"noEmit": true,
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"target": "es2023",
|
|
6
|
-
"module": "node20",
|
|
7
|
-
"moduleResolution": "node16",
|
|
8
|
-
"skipLibCheck": false,
|
|
9
|
-
"rootDirs": [
|
|
10
|
-
"./src",
|
|
11
|
-
"../.cedar/types/mirror/api/src"
|
|
12
|
-
],
|
|
13
|
-
"paths": {
|
|
14
|
-
"src/*": [
|
|
15
|
-
"./src/*",
|
|
16
|
-
"../.cedar/types/mirror/api/src/*"
|
|
17
|
-
],
|
|
18
|
-
"types/*": [
|
|
19
|
-
"./types/*",
|
|
20
|
-
"../types/*"
|
|
21
|
-
],
|
|
22
|
-
"@cedarjs/testing": [
|
|
23
|
-
"../node_modules/@cedarjs/testing/api"
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
"typeRoots": [
|
|
27
|
-
"../node_modules/@types",
|
|
28
|
-
"./node_modules/@types"
|
|
29
|
-
],
|
|
30
|
-
"types": [
|
|
31
|
-
"jest"
|
|
32
|
-
],
|
|
33
|
-
"jsx": "react-jsx"
|
|
34
|
-
},
|
|
35
|
-
"include": [
|
|
36
|
-
"src",
|
|
37
|
-
"../.cedar/types/includes/all-*",
|
|
38
|
-
"../.cedar/types/includes/api-*",
|
|
39
|
-
"../types"
|
|
40
|
-
]
|
|
41
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "api",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"private": true,
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@cedarjs/api": "7.0.0",
|
|
8
|
-
"@cedarjs/graphql-server": "7.0.0",
|
|
9
|
-
"@prisma/adapter-better-sqlite3": "7.8.0",
|
|
10
|
-
"@prisma/client": "7.8.0",
|
|
11
|
-
"better-sqlite3": "12.11.1",
|
|
12
|
-
"@cedarjs/context": "7.0.0",
|
|
13
|
-
"graphql-tag": "2.12.6"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@cedarjs/vite": "7.0.0",
|
|
17
|
-
"vitest": "4.1.10"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const { defineConfig, env } = require('prisma/config')
|
|
2
|
-
|
|
3
|
-
module.exports = defineConfig({
|
|
4
|
-
schema: 'db/schema.prisma',
|
|
5
|
-
migrations: {
|
|
6
|
-
path: 'db/migrations',
|
|
7
|
-
seed: '{{CEDAR_CLI}} exec seed',
|
|
8
|
-
},
|
|
9
|
-
datasource: {
|
|
10
|
-
url: env('DATABASE_URL'),
|
|
11
|
-
},
|
|
12
|
-
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { gql } from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { createValidatorDirective } from '@cedarjs/graphql-server'
|
|
4
|
-
|
|
5
|
-
import { requireAuth as applicationRequireAuth } from 'src/lib/auth'
|
|
6
|
-
|
|
7
|
-
export const schema = gql`
|
|
8
|
-
"""
|
|
9
|
-
Use to check whether or not a user is authenticated and is associated
|
|
10
|
-
with an optional set of roles.
|
|
11
|
-
"""
|
|
12
|
-
directive @requireAuth(roles: [String]) on FIELD_DEFINITION
|
|
13
|
-
`
|
|
14
|
-
|
|
15
|
-
const validate = ({ directiveArgs }) => {
|
|
16
|
-
const { roles } = directiveArgs
|
|
17
|
-
applicationRequireAuth({ roles })
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const requireAuth = createValidatorDirective(schema, validate)
|
|
21
|
-
|
|
22
|
-
export default requireAuth
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { mockRedwoodDirective, getDirectiveName } from '@cedarjs/testing/api'
|
|
2
|
-
|
|
3
|
-
import requireAuth from './requireAuth.js'
|
|
4
|
-
|
|
5
|
-
describe('requireAuth directive', () => {
|
|
6
|
-
it('declares the directive sdl as schema, with the correct name', () => {
|
|
7
|
-
expect(requireAuth.schema).toBeTruthy()
|
|
8
|
-
expect(getDirectiveName(requireAuth.schema)).toBe('requireAuth')
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('requireAuth has stub implementation. Should not throw when current user', () => {
|
|
12
|
-
// If you want to set values in context, pass it through e.g.
|
|
13
|
-
// mockRedwoodDirective(requireAuth, { context: { currentUser: { id: 1, name: 'Lebron McGretzky' } }})
|
|
14
|
-
const mockExecution = mockRedwoodDirective(requireAuth, { context: {} })
|
|
15
|
-
|
|
16
|
-
expect(mockExecution).not.toThrowError()
|
|
17
|
-
})
|
|
18
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { gql } from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { createValidatorDirective } from '@cedarjs/graphql-server'
|
|
4
|
-
|
|
5
|
-
export const schema = gql`
|
|
6
|
-
"""
|
|
7
|
-
Use to skip authentication checks and allow public access.
|
|
8
|
-
"""
|
|
9
|
-
directive @skipAuth on FIELD_DEFINITION
|
|
10
|
-
`
|
|
11
|
-
|
|
12
|
-
const skipAuth = createValidatorDirective(schema, () => {
|
|
13
|
-
return
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export default skipAuth
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getDirectiveName } from '@cedarjs/testing/api'
|
|
2
|
-
|
|
3
|
-
import skipAuth from './skipAuth.js'
|
|
4
|
-
|
|
5
|
-
describe('skipAuth directive', () => {
|
|
6
|
-
it('declares the directive sdl as schema, with the correct name', () => {
|
|
7
|
-
expect(skipAuth.schema).toBeTruthy()
|
|
8
|
-
expect(getDirectiveName(skipAuth.schema)).toBe('skipAuth')
|
|
9
|
-
})
|
|
10
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createGraphQLHandler } from '@cedarjs/graphql-server'
|
|
2
|
-
|
|
3
|
-
import directives from 'src/directives/**/*.{js,ts}'
|
|
4
|
-
import sdls from 'src/graphql/**/*.sdl.{js,ts}'
|
|
5
|
-
import services from 'src/services/**/*.{js,ts}'
|
|
6
|
-
|
|
7
|
-
import { db } from 'src/lib/db'
|
|
8
|
-
import { logger } from 'src/lib/logger'
|
|
9
|
-
|
|
10
|
-
export const handler = createGraphQLHandler({
|
|
11
|
-
loggerConfig: { logger, options: {} },
|
|
12
|
-
directives,
|
|
13
|
-
sdls,
|
|
14
|
-
services,
|
|
15
|
-
onException: () => {
|
|
16
|
-
// Disconnect from your database with an unhandled exception.
|
|
17
|
-
db.$disconnect()
|
|
18
|
-
},
|
|
19
|
-
})
|
|
File without changes
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Once you are ready to add authentication to your application
|
|
3
|
-
* you'll build out requireAuth() with real functionality. For
|
|
4
|
-
* now we just return `true` so that the calls in services
|
|
5
|
-
* have something to check against, simulating a logged
|
|
6
|
-
* in user that is allowed to access that service.
|
|
7
|
-
*
|
|
8
|
-
* See https://cedarjs.com/docs/authentication for more info.
|
|
9
|
-
*/
|
|
10
|
-
export const isAuthenticated = () => {
|
|
11
|
-
return true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const hasRole = ({ roles }) => {
|
|
15
|
-
return roles !== undefined
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// This is used by the cedar directive
|
|
19
|
-
// in ./api/src/directives/requireAuth
|
|
20
|
-
|
|
21
|
-
// Roles are passed in by the requireAuth directive if you have auth setup
|
|
22
|
-
// eslint-disable-next-line no-unused-vars
|
|
23
|
-
export const requireAuth = ({ roles }) => {
|
|
24
|
-
return isAuthenticated()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const getCurrentUser = async () => {
|
|
28
|
-
throw new Error(
|
|
29
|
-
'Auth is not set up yet. See https://cedarjs.com/docs/authentication ' +
|
|
30
|
-
'to get started'
|
|
31
|
-
)
|
|
32
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// See https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/constructor
|
|
2
|
-
// for options.
|
|
3
|
-
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
|
|
6
|
-
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3'
|
|
7
|
-
import { PrismaClient } from 'api/db/generated/prisma/client.mts'
|
|
8
|
-
|
|
9
|
-
import { emitLogLevels, handlePrismaLogging } from '@cedarjs/api/logger'
|
|
10
|
-
import { getPaths } from '@cedarjs/project-config'
|
|
11
|
-
|
|
12
|
-
import { logger } from './logger.js'
|
|
13
|
-
|
|
14
|
-
export * from 'api/db/generated/prisma/client.mts'
|
|
15
|
-
|
|
16
|
-
const resolveSqliteUrl = (url = 'file:./db/dev.db') => {
|
|
17
|
-
if (!url.startsWith('file:.')) {
|
|
18
|
-
return url
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const apiDir = getPaths().api.base
|
|
22
|
-
|
|
23
|
-
return `file:${path.resolve(apiDir, url.slice('file:'.length))}`
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const adapter = new PrismaBetterSqlite3({
|
|
27
|
-
url: resolveSqliteUrl(process.env.DATABASE_URL),
|
|
28
|
-
})
|
|
29
|
-
const prismaClient = new PrismaClient({
|
|
30
|
-
log: emitLogLevels(['info', 'warn', 'error']),
|
|
31
|
-
adapter,
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
handlePrismaLogging({
|
|
35
|
-
db: prismaClient,
|
|
36
|
-
logger,
|
|
37
|
-
logLevels: ['info', 'warn', 'error'],
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Global Prisma client extensions should be added here, as $extend
|
|
42
|
-
* returns a new instance.
|
|
43
|
-
* export const db = prismaClient.$extend(...)
|
|
44
|
-
* Add any .$on hooks before using $extend
|
|
45
|
-
*/
|
|
46
|
-
export const db = prismaClient
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@cedarjs/api/logger'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a logger with CedarLoggerOptions
|
|
5
|
-
*
|
|
6
|
-
* These extend and override default LoggerOptions,
|
|
7
|
-
* can define a destination like a file or other supported pino log transport stream,
|
|
8
|
-
* and sets whether or not to show the logger configuration settings (defaults to false)
|
|
9
|
-
*
|
|
10
|
-
* @param CedarLoggerOptions
|
|
11
|
-
*
|
|
12
|
-
* CedarLoggerOptions have
|
|
13
|
-
* @param {options} LoggerOptions - defines how to log, such as redaction and format
|
|
14
|
-
* @param {string | DestinationStream} destination - defines where to log, such as a transport stream or file
|
|
15
|
-
* @param {boolean} showConfig - whether to display logger configuration on initialization
|
|
16
|
-
*/
|
|
17
|
-
export const logger = createLogger({})
|
|
File without changes
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#:schema https://raw.githubusercontent.com/cedarjs/cedar/main/packages/project-config/cedar-toml-schema-2.0.json
|
|
2
|
-
#:tombi format.disabled = true
|
|
3
|
-
|
|
4
|
-
# This file contains the configuration settings for your Cedar app.
|
|
5
|
-
# This file is also what makes your Cedar app a Cedar app.
|
|
6
|
-
# If you remove it and try to run `yarn cedar dev`, you'll get an error.
|
|
7
|
-
#
|
|
8
|
-
# For the full list of options, see the "App Configuration: cedar.toml" doc:
|
|
9
|
-
# https://cedarjs.com/docs/app-configuration-cedar-toml
|
|
10
|
-
|
|
11
|
-
[web]
|
|
12
|
-
title = "Cedar App"
|
|
13
|
-
port = 8910
|
|
14
|
-
apiUrl = "/.api/functions"
|
|
15
|
-
includeEnvironmentVariables = [
|
|
16
|
-
# Add any ENV vars that should be available to the web side to this array
|
|
17
|
-
# See https://cedarjs.com/docs/environment-variables#web
|
|
18
|
-
]
|
|
19
|
-
[api]
|
|
20
|
-
port = 8911
|
|
21
|
-
[browser]
|
|
22
|
-
# Only applies to interactive sessions
|
|
23
|
-
# Override with `--fwd="--open=true"` (including for CI/agent runs)
|
|
24
|
-
open = true
|
|
25
|
-
[notifications]
|
|
26
|
-
versionUpdates = ["latest"]
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
.idea
|
|
2
|
-
.DS_Store
|
|
3
|
-
.env*
|
|
4
|
-
!.env.example
|
|
5
|
-
!.env.defaults
|
|
6
|
-
.netlify
|
|
7
|
-
.cedar/*
|
|
8
|
-
!.cedar/README.md
|
|
9
|
-
dev.db*
|
|
10
|
-
api/db/pglite-data
|
|
11
|
-
api/db/generated/prisma
|
|
12
|
-
dist
|
|
13
|
-
dist-babel
|
|
14
|
-
node_modules
|
|
15
|
-
tsconfig.tsbuildinfo
|
|
16
|
-
yarn-error.log
|
|
17
|
-
web/public/mockServiceWorker.js
|
|
18
|
-
web/types/graphql.d.ts
|
|
19
|
-
api/types/graphql.d.ts
|
|
20
|
-
api/src/lib/generateGraphiQLHeader.*
|
|
21
|
-
.pnp.*
|
|
22
|
-
.yarn/*
|
|
23
|
-
!.yarn/patches
|
|
24
|
-
!.yarn/plugins
|
|
25
|
-
!.yarn/releases
|
|
26
|
-
!.yarn/sdks
|
|
27
|
-
!.yarn/versions
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is used by the VSCode GraphQL extension
|
|
2
|
-
|
|
3
|
-
const { getPaths } = require('@cedarjs/project-config')
|
|
4
|
-
|
|
5
|
-
/** @type {import('graphql-config').IGraphQLConfig} */
|
|
6
|
-
const config = {
|
|
7
|
-
schema: getPaths().generated.schema,
|
|
8
|
-
documents: './web/src/**/!(*.d).{ts,tsx,js,jsx}',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = config
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": true,
|
|
3
|
-
"type": "module",
|
|
4
|
-
"workspaces": [
|
|
5
|
-
"api",
|
|
6
|
-
"web"
|
|
7
|
-
],
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "cedar build",
|
|
10
|
-
"dev": "cedar dev",
|
|
11
|
-
"start": "cedarjs-server",
|
|
12
|
-
"start:api": "cedarjs-server api",
|
|
13
|
-
"start:web": "cedarjs-server web"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@cedarjs/api-server": "7.0.0"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@cedarjs/core": "7.0.0",
|
|
20
|
-
"@cedarjs/eslint-config": "7.0.0",
|
|
21
|
-
"@cedarjs/project-config": "7.0.0",
|
|
22
|
-
"@cedarjs/testing": "7.0.0",
|
|
23
|
-
"vitest": "4.1.10"
|
|
24
|
-
},
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": "24.x"
|
|
27
|
-
},
|
|
28
|
-
"packageManager": "yarn@4.14.1",
|
|
29
|
-
"resolutions": {
|
|
30
|
-
"react-is": "19.2.3",
|
|
31
|
-
"vite": "7.3.6"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// https://prettier.io/docs/en/options.html
|
|
2
|
-
/** @type {import('prettier').RequiredOptions} */
|
|
3
|
-
module.exports = {
|
|
4
|
-
trailingComma: 'es5',
|
|
5
|
-
bracketSpacing: true,
|
|
6
|
-
tabWidth: 2,
|
|
7
|
-
semi: false,
|
|
8
|
-
singleQuote: true,
|
|
9
|
-
arrowParens: 'always',
|
|
10
|
-
overrides: [
|
|
11
|
-
{
|
|
12
|
-
files: 'Routes.*',
|
|
13
|
-
options: {
|
|
14
|
-
printWidth: 999,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
}
|
|
File without changes
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"noEmit": true,
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"target": "es2023",
|
|
6
|
-
"module": "node20",
|
|
7
|
-
"moduleResolution": "node16",
|
|
8
|
-
"rootDirs": [
|
|
9
|
-
"../api/src",
|
|
10
|
-
"../.cedar/types/mirror/api/src",
|
|
11
|
-
"../web/src",
|
|
12
|
-
"../.cedar/types/mirror/web/src"
|
|
13
|
-
],
|
|
14
|
-
"paths": {
|
|
15
|
-
"$api/*": [
|
|
16
|
-
"../api/*"
|
|
17
|
-
],
|
|
18
|
-
"api/*": [
|
|
19
|
-
"../api/*"
|
|
20
|
-
],
|
|
21
|
-
"$api/src/*": [
|
|
22
|
-
"../api/src/*",
|
|
23
|
-
"../.cedar/types/mirror/api/src/*"
|
|
24
|
-
],
|
|
25
|
-
"api/src/*": [
|
|
26
|
-
"../api/src/*",
|
|
27
|
-
"../.cedar/types/mirror/api/src/*"
|
|
28
|
-
],
|
|
29
|
-
"$web/*": [
|
|
30
|
-
"../web/*"
|
|
31
|
-
],
|
|
32
|
-
"web/*": [
|
|
33
|
-
"../web/*"
|
|
34
|
-
],
|
|
35
|
-
"$web/src/*": [
|
|
36
|
-
"../web/src/*",
|
|
37
|
-
"../.cedar/types/mirror/web/src/*"
|
|
38
|
-
],
|
|
39
|
-
"web/src/*": [
|
|
40
|
-
"../web/src/*",
|
|
41
|
-
"../.cedar/types/mirror/web/src/*"
|
|
42
|
-
],
|
|
43
|
-
"types/*": [
|
|
44
|
-
"../types/*",
|
|
45
|
-
"../web/types/*",
|
|
46
|
-
"../api/types/*"
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
"typeRoots": [
|
|
50
|
-
"../node_modules/@types"
|
|
51
|
-
],
|
|
52
|
-
"jsx": "preserve"
|
|
53
|
-
},
|
|
54
|
-
"include": [
|
|
55
|
-
".",
|
|
56
|
-
"../.cedar/types/includes/all-*",
|
|
57
|
-
"../.cedar/types/includes/web-*",
|
|
58
|
-
"../types"
|
|
59
|
-
]
|
|
60
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// import { db } from 'api/src/lib/db.js'
|
|
2
|
-
|
|
3
|
-
// Manually apply seeds via the `{{CEDAR_CLI}} prisma db seed` command.
|
|
4
|
-
//
|
|
5
|
-
// Seeds automatically run the first time you run the `{{CEDAR_CLI}} prisma migrate dev`
|
|
6
|
-
// command and every time you run the `{{CEDAR_CLI}} prisma migrate reset` command.
|
|
7
|
-
//
|
|
8
|
-
// See https://cedarjs.com/docs/database-seeds for more info
|
|
9
|
-
|
|
10
|
-
export default async () => {
|
|
11
|
-
try {
|
|
12
|
-
// Create your database records here! For example, seed some users:
|
|
13
|
-
//
|
|
14
|
-
// const users = [
|
|
15
|
-
// { name: 'Alice', email: 'alice@cedarjs.com' },
|
|
16
|
-
// { name: 'Bob', email: 'bob@cedarjs.com' },
|
|
17
|
-
// ]
|
|
18
|
-
//
|
|
19
|
-
// await db.user.createMany({ data: users })
|
|
20
|
-
|
|
21
|
-
console.info(
|
|
22
|
-
'\n No seed data, skipping. See scripts/seed.js to start seeding your database!\n'
|
|
23
|
-
)
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error(error)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body>
|
|
11
|
-
<!-- Please keep this div empty -->
|
|
12
|
-
<div id="cedar-app"></div>
|
|
13
|
-
</body>
|
|
14
|
-
|
|
15
|
-
</html>
|