-
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.
- Loading branch information
0 parents
commit 29ff183
Showing
103 changed files
with
28,971 additions
and
0 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,10 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
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,19 @@ | ||
# These environment variables will be used by default if you do not create any | ||
# yourself in .env. This file should be safe to check into your version control | ||
# system. Any custom values should go in .env and .env should *not* be checked | ||
# into version control. | ||
|
||
# schema.prisma defaults | ||
DATABASE_URL=file:./dev.db | ||
|
||
# location of the test database for api service scenarios (defaults to ./.redwood/test.db if not set) | ||
# TEST_DATABASE_URL=file:./.redwood/test.db | ||
|
||
# disables Prisma CLI update notifier | ||
PRISMA_HIDE_UPDATE_MESSAGE=true | ||
|
||
|
||
# Option to override the current environment's default api-side log level | ||
# See: https://redwoodjs.com/docs/logger for level options: | ||
# trace | info | debug | warn | error | silent | ||
# LOG_LEVEL=debug |
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,4 @@ | ||
# DATABASE_URL=file:./dev.db | ||
# TEST_DATABASE_URL=file:./.redwood/test.db | ||
# PRISMA_HIDE_UPDATE_MESSAGE=true | ||
# LOG_LEVEL=trace |
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,20 @@ | ||
.idea | ||
.DS_Store | ||
.env | ||
.netlify | ||
.redwood | ||
dev.db* | ||
dist | ||
dist-babel | ||
node_modules | ||
yarn-error.log | ||
web/public/mockServiceWorker.js | ||
web/types/graphql.d.ts | ||
api/types/graphql.d.ts | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions |
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 @@ | ||
lts/* |
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 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"eamodio.gitlens", | ||
"ofhumanbondage.react-proptypes-intellisense", | ||
"mgmcdermott.vscode-language-babel", | ||
"wix.vscode-import-cost", | ||
"pflannery.vscode-versionlens", | ||
"editorconfig.editorconfig", | ||
"prisma.prisma", | ||
"graphql.vscode-graphql" | ||
], | ||
"unwantedRecommendations": [] | ||
} |
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,26 @@ | ||
{ | ||
"version": "0.3.0", | ||
"configurations": [ | ||
{ | ||
"command": "yarn redwood dev --apiDebugPort 18911", | ||
"name": "Run Dev Server", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
}, | ||
{ | ||
"name": "Attach API debugger", | ||
"port": 18911, // you can change this port, see https://redwoodjs.com/docs/project-configuration-dev-test-build#debugger-configuration | ||
"request": "attach", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"type": "node", | ||
"protocol": "inspector", | ||
"stopOnEntry": false, | ||
"localRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist", | ||
"remoteRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist", | ||
"sourceMaps": true, | ||
"restart": true | ||
} | ||
] | ||
} |
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,11 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"files.trimTrailingWhitespace": true, | ||
"editor.formatOnSave": false, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
"[prisma]": { | ||
"editor.formatOnSave": true | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,17 @@ | ||
# Yarn's manifest file. You can configure yarn here. | ||
# See https://yarnpkg.com/configuration/yarnrc. | ||
|
||
# For `node_modules` (see `nodeLinker` below), this is almost always the preferred option. | ||
compressionLevel: 0 | ||
|
||
enableGlobalCache: true | ||
|
||
# Lets yarn use hardlinks inside `node_modules` to dedupe packages. | ||
# For a more pnpm-like experience, consider `hardlinks-global` where hardlinks point to a global store. | ||
nmMode: hardlinks-local | ||
|
||
# How to install Node packages. | ||
# Heads up: right now, Redwood expects this to be `node-modules`. | ||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-3.2.1.cjs |
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,121 @@ | ||
# README | ||
|
||
Welcome to [RedwoodJS](https://redwoodjs.com)! | ||
|
||
> **Prerequisites** | ||
> | ||
> - Redwood requires [Node.js](https://nodejs.org/en/) (>=14.19.x <=16.x) and [Yarn](https://yarnpkg.com/) (>=1.15) | ||
> - Are you on Windows? For best results, follow our [Windows development setup](https://redwoodjs.com/docs/how-to/windows-development-setup) guide | ||
Start by installing dependencies: | ||
|
||
``` | ||
yarn install | ||
``` | ||
|
||
Then change into that directory and start the development server: | ||
|
||
``` | ||
cd my-redwood-project | ||
yarn redwood dev | ||
``` | ||
|
||
Your browser should automatically open to http://localhost:8910 where you'll see the Welcome Page, which links out to a ton of great resources. | ||
|
||
> **The Redwood CLI** | ||
> | ||
> Congratulations on running your first Redwood CLI command! | ||
> From dev to deploy, the CLI is with you the whole way. | ||
> And there's quite a few commands at your disposal: | ||
> ``` | ||
> yarn redwood --help | ||
> ``` | ||
> For all the details, see the [CLI reference](https://redwoodjs.com/docs/cli-commands). | ||
## Prisma and the database | ||
Redwood wouldn't be a full-stack framework without a database. It all starts with the schema. Open the [`schema.prisma`](api/db/schema.prisma) file in `api/db` and replace the `UserExample` model with the following `Post` model: | ||
``` | ||
model Post { | ||
id Int @id @default(autoincrement()) | ||
title String | ||
body String | ||
createdAt DateTime @default(now()) | ||
} | ||
``` | ||
Redwood uses [Prisma](https://www.prisma.io/), a next-gen Node.js and TypeScript ORM, to talk to the database. Prisma's schema offers a declarative way of defining your app's data models. And Prisma [Migrate](https://www.prisma.io/migrate) uses that schema to make database migrations hassle-free: | ||
``` | ||
yarn rw prisma migrate dev | ||
|
||
# ... | ||
|
||
? Enter a name for the new migration: › create posts | ||
``` | ||
> `rw` is short for `redwood` | ||
You'll be prompted for the name of your migration. `create posts` will do. | ||
Now let's generate everything we need to perform all the CRUD (Create, Retrieve, Update, Delete) actions on our `Post` model: | ||
``` | ||
yarn redwood g scaffold post | ||
``` | ||
Navigate to http://localhost:8910/posts/new, fill in the title and body, and click "Save": | ||
Did we just create a post in the database? Yup! With `yarn rw g scaffold <model>`, Redwood created all the pages, components, and services necessary to perform all CRUD actions on our posts table. | ||
## Frontend first with Storybook | ||
Don't know what your data models look like? | ||
That's more than ok—Redwood integrates Storybook so that you can work on design without worrying about data. | ||
Mockup, build, and verify your React components, even in complete isolation from the backend: | ||
``` | ||
yarn rw storybook | ||
``` | ||
Before you start, see if the CLI's `setup ui` command has your favorite styling library: | ||
``` | ||
yarn rw setup ui --help | ||
``` | ||
## Testing with Jest | ||
It'd be hard to scale from side project to startup without a few tests. | ||
Redwood fully integrates Jest with the front and the backends and makes it easy to keep your whole app covered by generating test files with all your components and services: | ||
``` | ||
yarn rw test | ||
``` | ||
To make the integration even more seamless, Redwood augments Jest with database [scenarios](https://redwoodjs.com/docs/testing.md#scenarios) and [GraphQL mocking](https://redwoodjs.com/docs/testing.md#mocking-graphql-calls). | ||
## Ship it | ||
Redwood is designed for both serverless deploy targets like Netlify and Vercel and serverful deploy targets like Render and AWS: | ||
``` | ||
yarn rw setup deploy --help | ||
``` | ||
Don't go live without auth! | ||
Lock down your front and backends with Redwood's built-in, database-backed authentication system ([dbAuth](https://redwoodjs.com/docs/authentication#self-hosted-auth-installation-and-setup)), or integrate with nearly a dozen third party auth providers: | ||
``` | ||
yarn rw setup auth --help | ||
``` | ||
## Next Steps | ||
The best way to learn Redwood is by going through the comprehensive [tutorial](https://redwoodjs.com/docs/tutorial/foreword) and joining the community (via the [Discourse forum](https://community.redwoodjs.com) or the [Discord server](https://discord.gg/redwoodjs)). | ||
## Quick Links | ||
- Stay updated: read [Forum announcements](https://community.redwoodjs.com/c/announcements/5), follow us on [Twitter](https://twitter.com/redwoodjs), and subscribe to the [newsletter](https://redwoodjs.com/newsletter) | ||
- [Learn how to contribute](https://redwoodjs.com/docs/contributing) |
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,7 @@ | ||
-- CreateTable | ||
CREATE TABLE "Post" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"title" TEXT NOT NULL, | ||
"body" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); |
8 changes: 8 additions & 0 deletions
8
api/db/migrations/20220703080722_create_contact/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,8 @@ | ||
-- CreateTable | ||
CREATE TABLE "Contact" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"name" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"message" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); |
13 changes: 13 additions & 0 deletions
13
api/db/migrations/20220703081639_create_e_user/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,13 @@ | ||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"name" TEXT, | ||
"email" TEXT NOT NULL, | ||
"hashedPassword" TEXT NOT NULL, | ||
"salt" TEXT NOT NULL, | ||
"resetToken" TEXT, | ||
"resetTokenExpiresAt" DATETIME | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); |
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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "sqlite" |
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,34 @@ | ||
datasource db { | ||
provider = "sqlite" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
binaryTargets = "native" | ||
} | ||
|
||
model Post { | ||
id Int @id @default(autoincrement()) | ||
title String | ||
body String | ||
createdAt DateTime @default(now()) | ||
} | ||
|
||
model Contact { | ||
id Int @id @default(autoincrement()) | ||
name String | ||
email String | ||
message String | ||
createdAt DateTime @default(now()) | ||
} | ||
|
||
model User { | ||
id Int @id @default(autoincrement()) | ||
name String? | ||
email String @unique | ||
hashedPassword String | ||
salt String | ||
resetToken String? | ||
resetTokenExpiresAt DateTime? | ||
} |
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,8 @@ | ||
// More info at https://redwoodjs.com/docs/project-configuration-dev-test-build | ||
|
||
const config = { | ||
rootDir: '../', | ||
preset: '@redwoodjs/testing/config/jest/api', | ||
} | ||
|
||
module.exports = config |
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,9 @@ | ||
{ | ||
"name": "api", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@redwoodjs/api": "2.0.0", | ||
"@redwoodjs/graphql-server": "2.0.0" | ||
} | ||
} |
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 @@ | ||
/** | ||
* This file allows you to configure the Fastify Server settings | ||
* used by the RedwoodJS dev server. | ||
* | ||
* It also applies when running the api server with `yarn rw serve`. | ||
* | ||
* For the Fastify server options that you can set, see: | ||
* https://www.fastify.io/docs/latest/Reference/Server/#factory | ||
* | ||
* Examples include: logger settings, timeouts, maximum payload limits, and more. | ||
* | ||
* Note: This configuration does not apply in a serverless deploy. | ||
*/ | ||
|
||
/** @type {import('fastify').FastifyServerOptions} */ | ||
const config = { | ||
requestTimeout: 15_000, | ||
logger: { | ||
level: process.env.NODE_ENV === 'development' ? 'debug' : 'warn', | ||
}, | ||
} | ||
|
||
module.exports = config |
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,18 @@ | ||
import { mockRedwoodDirective, getDirectiveName } from '@redwoodjs/testing/api' | ||
|
||
import requireAuth from './requireAuth' | ||
|
||
describe('requireAuth directive', () => { | ||
it('declares the directive sdl as schema, with the correct name', () => { | ||
expect(requireAuth.schema).toBeTruthy() | ||
expect(getDirectiveName(requireAuth.schema)).toBe('requireAuth') | ||
}) | ||
|
||
it('requireAuth has stub implementation. Should not throw when current user', () => { | ||
// If you want to set values in context, pass it through e.g. | ||
// mockRedwoodDirective(requireAuth, { context: { currentUser: { id: 1, name: 'Lebron McGretzky' } }}) | ||
const mockExecution = mockRedwoodDirective(requireAuth, { context: {} }) | ||
|
||
expect(mockExecution).not.toThrowError() | ||
}) | ||
}) |
Oops, something went wrong.