create-cedar-app 0.7.2-next.2 → 0.7.2-next.50
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/dist/create-cedar-app.js +94 -94
- package/package.json +7 -6
- package/templates/esm-js/.editorconfig +10 -0
- package/templates/esm-js/.env +15 -0
- package/templates/esm-js/.env.defaults +19 -0
- package/templates/esm-js/.env.example +4 -0
- package/templates/esm-js/.redwood/README.md +44 -0
- package/templates/esm-js/.vscode/extensions.json +14 -0
- package/templates/esm-js/.vscode/launch.json +56 -0
- package/templates/esm-js/.vscode/settings.json +11 -0
- package/templates/esm-js/.vscode/tasks.json +29 -0
- package/templates/esm-js/.yarnrc.yml +15 -0
- package/templates/esm-js/README.md +17 -0
- package/templates/esm-js/api/db/schema.prisma +24 -0
- package/templates/esm-js/api/jsconfig.json +41 -0
- package/templates/esm-js/api/package.json +10 -0
- package/templates/esm-js/api/src/directives/requireAuth/requireAuth.js +22 -0
- package/templates/esm-js/api/src/directives/requireAuth/requireAuth.test.js +18 -0
- package/templates/esm-js/api/src/directives/skipAuth/skipAuth.js +16 -0
- package/templates/esm-js/api/src/directives/skipAuth/skipAuth.test.js +10 -0
- package/templates/esm-js/api/src/functions/graphql.js +19 -0
- package/templates/esm-js/api/src/graphql/.keep +0 -0
- package/templates/esm-js/api/src/lib/auth.js +32 -0
- package/templates/esm-js/api/src/lib/db.js +26 -0
- package/templates/esm-js/api/src/lib/logger.js +17 -0
- package/templates/esm-js/api/src/services/.keep +0 -0
- package/templates/esm-js/api/vitest.config.js +10 -0
- package/templates/esm-js/gitignore.template +24 -0
- package/templates/esm-js/graphql.config.cjs +11 -0
- package/templates/esm-js/package.json +32 -0
- package/templates/esm-js/prettier.config.cjs +18 -0
- package/templates/esm-js/redwood.toml +21 -0
- package/templates/esm-js/scripts/.keep +0 -0
- package/templates/esm-js/scripts/jsconfig.json +54 -0
- package/templates/esm-js/scripts/seed.js +27 -0
- package/templates/esm-js/vitest.config.mjs +7 -0
- package/templates/esm-js/web/jsconfig.json +53 -0
- package/templates/esm-js/web/package.json +26 -0
- package/templates/esm-js/web/public/README.md +43 -0
- package/templates/esm-js/web/public/favicon.png +0 -0
- package/templates/esm-js/web/public/robots.txt +2 -0
- package/templates/esm-js/web/src/App.jsx +16 -0
- package/templates/esm-js/web/src/Routes.jsx +20 -0
- package/templates/esm-js/web/src/components/.keep +0 -0
- package/templates/esm-js/web/src/entry.client.jsx +35 -0
- package/templates/esm-js/web/src/index.css +0 -0
- package/templates/esm-js/web/src/index.html +15 -0
- package/templates/esm-js/web/src/layouts/.keep +0 -0
- package/templates/esm-js/web/src/pages/FatalErrorPage/FatalErrorPage.jsx +58 -0
- package/templates/esm-js/web/src/pages/NotFoundPage/NotFoundPage.jsx +45 -0
- package/templates/esm-js/web/vite.config.js +21 -0
- package/templates/esm-js/web/vitest.setup.js +12 -0
- package/templates/esm-ts/.editorconfig +10 -0
- package/templates/esm-ts/.env +15 -0
- package/templates/esm-ts/.env.defaults +19 -0
- package/templates/esm-ts/.env.example +4 -0
- package/templates/esm-ts/.redwood/README.md +44 -0
- package/templates/esm-ts/.vscode/extensions.json +14 -0
- package/templates/esm-ts/.vscode/launch.json +56 -0
- package/templates/esm-ts/.vscode/settings.json +11 -0
- package/templates/esm-ts/.vscode/tasks.json +29 -0
- package/templates/esm-ts/.yarnrc.yml +15 -0
- package/templates/esm-ts/README.md +17 -0
- package/templates/esm-ts/api/db/schema.prisma +24 -0
- package/templates/esm-ts/api/package.json +10 -0
- package/templates/esm-ts/api/src/directives/requireAuth/requireAuth.test.ts +18 -0
- package/templates/esm-ts/api/src/directives/requireAuth/requireAuth.ts +25 -0
- package/templates/esm-ts/api/src/directives/skipAuth/skipAuth.test.ts +10 -0
- package/templates/esm-ts/api/src/directives/skipAuth/skipAuth.ts +16 -0
- package/templates/esm-ts/api/src/functions/graphql.ts +19 -0
- package/templates/esm-ts/api/src/graphql/.keep +0 -0
- package/templates/esm-ts/api/src/lib/auth.ts +32 -0
- package/templates/esm-ts/api/src/lib/db.ts +26 -0
- package/templates/esm-ts/api/src/lib/logger.ts +17 -0
- package/templates/esm-ts/api/src/services/.keep +0 -0
- package/templates/esm-ts/api/tsconfig.json +26 -0
- package/templates/esm-ts/api/vitest.config.ts +10 -0
- package/templates/esm-ts/gitignore.template +24 -0
- package/templates/esm-ts/graphql.config.cjs +11 -0
- package/templates/esm-ts/package.json +32 -0
- package/templates/esm-ts/prettier.config.cjs +18 -0
- package/templates/esm-ts/redwood.toml +21 -0
- package/templates/esm-ts/scripts/.keep +0 -0
- package/templates/esm-ts/scripts/seed.ts +27 -0
- package/templates/esm-ts/scripts/tsconfig.json +29 -0
- package/templates/esm-ts/vitest.config.ts +7 -0
- package/templates/esm-ts/web/package.json +26 -0
- package/templates/esm-ts/web/public/README.md +43 -0
- package/templates/esm-ts/web/public/favicon.png +0 -0
- package/templates/esm-ts/web/public/robots.txt +2 -0
- package/templates/esm-ts/web/src/App.tsx +22 -0
- package/templates/esm-ts/web/src/Routes.tsx +20 -0
- package/templates/esm-ts/web/src/components/.keep +0 -0
- package/templates/esm-ts/web/src/entry.client.tsx +35 -0
- package/templates/esm-ts/web/src/index.css +0 -0
- package/templates/esm-ts/web/src/index.html +15 -0
- package/templates/esm-ts/web/src/layouts/.keep +0 -0
- package/templates/esm-ts/web/src/pages/FatalErrorPage/FatalErrorPage.tsx +57 -0
- package/templates/esm-ts/web/src/pages/NotFoundPage/NotFoundPage.tsx +44 -0
- package/templates/esm-ts/web/tsconfig.json +44 -0
- package/templates/esm-ts/web/vite.config.ts +21 -0
- package/templates/esm-ts/web/vitest.setup.ts +12 -0
- package/templates/js/api/package.json +2 -2
- package/templates/js/package.json +3 -3
- package/templates/js/web/package.json +4 -4
- package/templates/ts/api/package.json +2 -2
- package/templates/ts/package.json +3 -3
- package/templates/ts/web/package.json +4 -4
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Yarn's manifest file. You can configure yarn here.
|
|
2
|
+
# See https://yarnpkg.com/configuration/yarnrc.
|
|
3
|
+
|
|
4
|
+
# For `node_modules` (see `nodeLinker` below), this is almost always the preferred option.
|
|
5
|
+
compressionLevel: 0
|
|
6
|
+
|
|
7
|
+
enableGlobalCache: true
|
|
8
|
+
|
|
9
|
+
# Lets yarn use hardlinks inside `node_modules` to dedupe packages.
|
|
10
|
+
# For a more pnpm-like experience, consider `hardlinks-global` where hardlinks point to a global store.
|
|
11
|
+
nmMode: hardlinks-local
|
|
12
|
+
|
|
13
|
+
# How to install Node packages.
|
|
14
|
+
# Heads up: right now, Redwood expects this to be `node-modules`.
|
|
15
|
+
nodeLinker: node-modules
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# README
|
|
2
|
+
|
|
3
|
+
Welcome to your new [CedarJS](https://cedarjs.com) project!
|
|
4
|
+
|
|
5
|
+
Start by installing dependencies:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Then start the development server:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
yarn redwood 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.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Don't forget to tell Prisma about your edits to this file using
|
|
2
|
+
// `yarn rw prisma migrate dev` or `yarn rw 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
|
+
url = env("DATABASE_URL")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
generator client {
|
|
13
|
+
provider = "prisma-client-js"
|
|
14
|
+
binaryTargets = "native"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Define your own datamodels here and run `yarn redwood prisma migrate dev`
|
|
18
|
+
// to create migrations for them and apply to your dev DB.
|
|
19
|
+
// TODO: Please remove the following example:
|
|
20
|
+
model UserExample {
|
|
21
|
+
id Int @id @default(autoincrement())
|
|
22
|
+
email String @unique
|
|
23
|
+
name String?
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag'
|
|
2
|
+
|
|
3
|
+
import type { ValidatorDirectiveFunc } from '@cedarjs/graphql-server'
|
|
4
|
+
import { createValidatorDirective } from '@cedarjs/graphql-server'
|
|
5
|
+
|
|
6
|
+
import { requireAuth as applicationRequireAuth } from 'src/lib/auth.js'
|
|
7
|
+
|
|
8
|
+
export const schema = gql`
|
|
9
|
+
"""
|
|
10
|
+
Use to check whether or not a user is authenticated and is associated
|
|
11
|
+
with an optional set of roles.
|
|
12
|
+
"""
|
|
13
|
+
directive @requireAuth(roles: [String]) on FIELD_DEFINITION
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
type RequireAuthValidate = ValidatorDirectiveFunc<{ roles?: string[] }>
|
|
17
|
+
|
|
18
|
+
const validate: RequireAuthValidate = ({ directiveArgs }) => {
|
|
19
|
+
const { roles } = directiveArgs
|
|
20
|
+
applicationRequireAuth({ roles })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const requireAuth = createValidatorDirective(schema, validate)
|
|
24
|
+
|
|
25
|
+
export default requireAuth
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
|
@@ -0,0 +1,19 @@
|
|
|
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.js'
|
|
8
|
+
import { logger } from 'src/lib/logger.js'
|
|
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
|
|
@@ -0,0 +1,32 @@
|
|
|
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://redwoodjs.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 redwood 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 @typescript-eslint/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://redwoodjs.com/docs/authentication ' +
|
|
30
|
+
'to get started'
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// See https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/constructor
|
|
2
|
+
// for options.
|
|
3
|
+
|
|
4
|
+
import { PrismaClient } from '@prisma/client'
|
|
5
|
+
|
|
6
|
+
import { emitLogLevels, handlePrismaLogging } from '@cedarjs/api/logger'
|
|
7
|
+
|
|
8
|
+
import { logger } from './logger.js'
|
|
9
|
+
|
|
10
|
+
const prismaClient = new PrismaClient({
|
|
11
|
+
log: emitLogLevels(['info', 'warn', 'error']),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
handlePrismaLogging({
|
|
15
|
+
db: prismaClient,
|
|
16
|
+
logger,
|
|
17
|
+
logLevels: ['info', 'warn', 'error'],
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Global Prisma client extensions should be added here, as $extend
|
|
22
|
+
* returns a new instance.
|
|
23
|
+
* export const db = prismaClient.$extend(...)
|
|
24
|
+
* Add any .$on hooks before using $extend
|
|
25
|
+
*/
|
|
26
|
+
export const db = prismaClient
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createLogger } from '@cedarjs/api/logger'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a logger with RedwoodLoggerOptions
|
|
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 RedwoodLoggerOptions
|
|
11
|
+
*
|
|
12
|
+
* RedwoodLoggerOptions 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
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"noEmit": true,
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"target": "ES2023",
|
|
7
|
+
"module": "Node16",
|
|
8
|
+
"moduleResolution": "Node16",
|
|
9
|
+
"skipLibCheck": false,
|
|
10
|
+
"rootDirs": ["./src", "../.redwood/types/mirror/api/src"],
|
|
11
|
+
"paths": {
|
|
12
|
+
"src/*": ["./src/*", "../.redwood/types/mirror/api/src/*"],
|
|
13
|
+
"types/*": ["./types/*", "../types/*"],
|
|
14
|
+
"@cedarjs/testing": ["../node_modules/@cedarjs/testing/api"]
|
|
15
|
+
},
|
|
16
|
+
"typeRoots": ["../node_modules/@types", "./node_modules/@types"],
|
|
17
|
+
"types": ["jest"],
|
|
18
|
+
"jsx": "react-jsx"
|
|
19
|
+
},
|
|
20
|
+
"include": [
|
|
21
|
+
"src",
|
|
22
|
+
"../.redwood/types/includes/all-*",
|
|
23
|
+
"../.redwood/types/includes/api-*",
|
|
24
|
+
"../types"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.idea
|
|
2
|
+
.DS_Store
|
|
3
|
+
.env*
|
|
4
|
+
!.env.example
|
|
5
|
+
!.env.defaults
|
|
6
|
+
.netlify
|
|
7
|
+
.redwood/*
|
|
8
|
+
!.redwood/README.md
|
|
9
|
+
dev.db*
|
|
10
|
+
dist
|
|
11
|
+
dist-babel
|
|
12
|
+
node_modules
|
|
13
|
+
yarn-error.log
|
|
14
|
+
web/public/mockServiceWorker.js
|
|
15
|
+
web/types/graphql.d.ts
|
|
16
|
+
api/types/graphql.d.ts
|
|
17
|
+
api/src/lib/generateGraphiQLHeader.*
|
|
18
|
+
.pnp.*
|
|
19
|
+
.yarn/*
|
|
20
|
+
!.yarn/patches
|
|
21
|
+
!.yarn/plugins
|
|
22
|
+
!.yarn/releases
|
|
23
|
+
!.yarn/sdks
|
|
24
|
+
!.yarn/versions
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"type": "module",
|
|
4
|
+
"workspaces": {
|
|
5
|
+
"packages": [
|
|
6
|
+
"api",
|
|
7
|
+
"web"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@cedarjs/core": "0.0.5",
|
|
12
|
+
"@cedarjs/project-config": "0.0.5",
|
|
13
|
+
"@cedarjs/testing": "0.0.5",
|
|
14
|
+
"vitest": "3.2.4"
|
|
15
|
+
},
|
|
16
|
+
"eslintConfig": {
|
|
17
|
+
"extends": "@cedarjs/eslint-config",
|
|
18
|
+
"root": true
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "=20.x"
|
|
22
|
+
},
|
|
23
|
+
"prisma": {
|
|
24
|
+
"seed": "yarn rw exec seed"
|
|
25
|
+
},
|
|
26
|
+
"packageManager": "yarn@4.9.2",
|
|
27
|
+
"resolutions": {
|
|
28
|
+
"@storybook/react-dom-shim@npm:7.6.20": "https://verdaccio.tobbe.dev/@storybook/react-dom-shim/-/react-dom-shim-8.0.8.tgz",
|
|
29
|
+
"react-is": "19.0.0-rc-f2df5694-20240916",
|
|
30
|
+
"vite": "5.4.19"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file contains the configuration settings for your Redwood app.
|
|
2
|
+
# This file is also what makes your Redwood app a Redwood app.
|
|
3
|
+
# If you remove it and try to run `yarn rw dev`, you'll get an error.
|
|
4
|
+
#
|
|
5
|
+
# For the full list of options, see the "App Configuration: redwood.toml" doc:
|
|
6
|
+
# https://redwoodjs.com/docs/app-configuration-redwood-toml
|
|
7
|
+
|
|
8
|
+
[web]
|
|
9
|
+
title = "Cedar App"
|
|
10
|
+
port = 8910
|
|
11
|
+
apiUrl = "/.redwood/functions"
|
|
12
|
+
includeEnvironmentVariables = [
|
|
13
|
+
# Add any ENV vars that should be available to the web side to this array
|
|
14
|
+
# See https://redwoodjs.com/docs/environment-variables#web
|
|
15
|
+
]
|
|
16
|
+
[api]
|
|
17
|
+
port = 8911
|
|
18
|
+
[browser]
|
|
19
|
+
open = true
|
|
20
|
+
[notifications]
|
|
21
|
+
versionUpdates = ["latest"]
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// import { db } from 'api/src/lib/db.js'
|
|
2
|
+
|
|
3
|
+
// Manually apply seeds via the `yarn rw prisma db seed` command.
|
|
4
|
+
//
|
|
5
|
+
// Seeds automatically run the first time you run the `yarn rw prisma migrate dev`
|
|
6
|
+
// command and every time you run the `yarn rw prisma migrate reset` command.
|
|
7
|
+
//
|
|
8
|
+
// See https://redwoodjs.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.ts to start seeding your database!\n'
|
|
23
|
+
)
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(error)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"noEmit": true,
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"target": "ES2023",
|
|
7
|
+
"module": "Node16",
|
|
8
|
+
"moduleResolution": "Node16",
|
|
9
|
+
"paths": {
|
|
10
|
+
"$api/*": ["../api/*"],
|
|
11
|
+
"api/*": ["../api/*"],
|
|
12
|
+
"$api/src/*": ["../api/src/*", "../.redwood/types/mirror/api/src/*"],
|
|
13
|
+
"api/src/*": ["../api/src/*", "../.redwood/types/mirror/api/src/*"],
|
|
14
|
+
"$web/*": ["../web/*"],
|
|
15
|
+
"web/*": ["../web/*"],
|
|
16
|
+
"$web/src/*": ["../web/src/*", "../.redwood/types/mirror/web/src/*"],
|
|
17
|
+
"web/src/*": ["../web/src/*", "../.redwood/types/mirror/web/src/*"],
|
|
18
|
+
"types/*": ["../types/*", "../web/types/*", "../api/types/*"]
|
|
19
|
+
},
|
|
20
|
+
"typeRoots": ["../node_modules/@types"],
|
|
21
|
+
"jsx": "preserve"
|
|
22
|
+
},
|
|
23
|
+
"include": [
|
|
24
|
+
".",
|
|
25
|
+
"../.redwood/types/includes/all-*",
|
|
26
|
+
"../.redwood/types/includes/web-*",
|
|
27
|
+
"../types"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "web",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"browserslist": {
|
|
7
|
+
"development": [
|
|
8
|
+
"last 1 version"
|
|
9
|
+
],
|
|
10
|
+
"production": [
|
|
11
|
+
"defaults"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@cedarjs/forms": "0.0.5",
|
|
16
|
+
"@cedarjs/router": "0.0.5",
|
|
17
|
+
"@cedarjs/web": "0.0.5",
|
|
18
|
+
"react": "19.0.0-rc-f2df5694-20240916",
|
|
19
|
+
"react-dom": "19.0.0-rc-f2df5694-20240916"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@cedarjs/vite": "0.0.5",
|
|
23
|
+
"@types/react": "^18.2.55",
|
|
24
|
+
"@types/react-dom": "^18.2.19"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Static Assets
|
|
2
|
+
|
|
3
|
+
Use this folder to add static files directly to your app. All included files and folders will be copied directly into the `/dist` folder (created when Vite builds for production). They will also be available during development when you run `yarn rw dev`.
|
|
4
|
+
|
|
5
|
+
> Note: files will _not_ hot reload while the development server is running. You'll need to manually stop/start to access file changes.
|
|
6
|
+
|
|
7
|
+
### Example Use
|
|
8
|
+
|
|
9
|
+
A file like `favicon.png` will be copied to `/dist/favicon.png`. A folder containing a file such as `static-files/my-logo.jpg` will be copied to `/dist/static-files/my-logo.jpg`. These can be referenced in your code directly without any special handling, e.g.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
and
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
<img src="/static-files/my-logo.jpg"> alt="Logo" />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Best Practices
|
|
22
|
+
|
|
23
|
+
Because assets in this folder are bypassing the javascript module system, **this folder should be used sparingly** for assets such as favicons, robots.txt, manifests, libraries incompatible with Vite, etc.
|
|
24
|
+
|
|
25
|
+
In general, it's best to import files directly into a template, page, or component. This allows Vite to include that file in the bundle when small enough, or to copy it over to the `dist` folder with a hash.
|
|
26
|
+
|
|
27
|
+
### Example Asset Import with Vite
|
|
28
|
+
|
|
29
|
+
Instead of handling our logo image as a static file per the example above, we can do the following:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
import React from "react"
|
|
33
|
+
import logo from "./my-logo.jpg"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function Header() {
|
|
37
|
+
return <img src={logo} alt="Logo" />
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default Header
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
See Vite's docs for [static asset handling](https://vitejs.dev/guide/assets.html)
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { FatalErrorBoundary, RedwoodProvider } from '@cedarjs/web'
|
|
4
|
+
import { RedwoodApolloProvider } from '@cedarjs/web/apollo'
|
|
5
|
+
|
|
6
|
+
import FatalErrorPage from 'src/pages/FatalErrorPage'
|
|
7
|
+
|
|
8
|
+
import './index.css'
|
|
9
|
+
|
|
10
|
+
interface AppProps {
|
|
11
|
+
children?: ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const App = ({ children }: AppProps) => (
|
|
15
|
+
<FatalErrorBoundary page={FatalErrorPage}>
|
|
16
|
+
<RedwoodProvider titleTemplate="%PageTitle | %AppTitle">
|
|
17
|
+
<RedwoodApolloProvider>{children}</RedwoodApolloProvider>
|
|
18
|
+
</RedwoodProvider>
|
|
19
|
+
</FatalErrorBoundary>
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
export default App
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// In this file, all Page components from 'src/pages` are auto-imported. Nested
|
|
2
|
+
// directories are supported, and should be uppercase. Each subdirectory will be
|
|
3
|
+
// prepended onto the component name.
|
|
4
|
+
//
|
|
5
|
+
// Examples:
|
|
6
|
+
//
|
|
7
|
+
// 'src/pages/HomePage/HomePage.js' -> HomePage
|
|
8
|
+
// 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage
|
|
9
|
+
|
|
10
|
+
import { Router, Route } from '@cedarjs/router'
|
|
11
|
+
|
|
12
|
+
const Routes = () => {
|
|
13
|
+
return (
|
|
14
|
+
<Router>
|
|
15
|
+
<Route notfound page={NotFoundPage} />
|
|
16
|
+
</Router>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default Routes
|
|
File without changes
|