Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

26.0.1 #5

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
78 changes: 40 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# keystone
.keystone
app.db
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules/
.pnp
.pnp.js

# testing
coverage/

# next.js
.next/
out/

# production
build/

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# keystone
.keystone/
app.db

migrations/migration_lock.toml
130 changes: 65 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
# Prisma Day 2021 Workshop

This is the sample app built for Jed's Prisma Day 2021 Workshop.

It's both the front and back-end for a Blog built with Prisma, KeystoneJS, GraphQL, Next.js and Tailwind.

The App includes public auth and signup, role-based access control, and custom design-system based components in the Content field. Content authors can embed Polls in post content, and authenticated visitors can vote on responses.

## About KeystoneJS

**Keystone 6** is the next-gen CMS for Node.js built with Prisma, Apollo Server, and Next.js.

Fully open source, it's not just a great headless CMS, it's also a powerful API server and app back-end.

Learn more at [keystonejs.com](https://keystonejs.com)

## Running this app

Make sure you have:

- Node v12 or v14
- Yarn
- Postgres

Then, clone this repo and run `yarn` to install the dependencies.

### Starting the API

Start the API Server first by running `yarn api:dev`. This will start Keystone's GraphQL API and Admin UI on `localhost:3000`

The first time you open that link you will be prompted to create a new user.

### Starting the Site

With the API running, in a separate terminal run `yarn site:dev`. This will start the front-end Next.js app on `localhost:8000`

## About the codebase

The Keystone and Next.js app are colocated in the same repo for ease of demonstration, but you'd often separate them into different packages in a monorepo or even separate repositories.

The back-end files include:

```
keystone.ts
schema.graphql (generated)
schema.prisma (generated)
schema.ts
schema/*
```

The front-end files include:

```
components/*
pages/*
next-env.d.ts
next.config.js
postcss.config.js
tailwind.config.js
utils.js
```

## License

Copyright (c) 2021 Thinkmill Labs Pty Ltd. Licensed under the MIT License.
# Prisma Day 2021 Workshop
This is the sample app built for Jed's Prisma Day 2021 Workshop.
It's both the front and back-end for a Blog built with Prisma, KeystoneJS, GraphQL, Next.js and Tailwind.
The App includes public auth and signup, role-based access control, and custom design-system based components in the Content field. Content authors can embed Polls in post content, and authenticated visitors can vote on responses.
## About KeystoneJS
**Keystone 6** is the next-gen CMS for Node.js built with Prisma, Apollo Server, and Next.js.
Fully open source, it's not just a great headless CMS, it's also a powerful API server and app back-end.
Learn more at [keystonejs.com](https://keystonejs.com)
## Running this app
Make sure you have:
- Node v12 or v14
- Yarn
- Postgres
Then, clone this repo and run `yarn` to install the dependencies.
### Starting the API
Start the API Server first by running `yarn api:dev`. This will start Keystone's GraphQL API and Admin UI on `localhost:3000`
The first time you open that link you will be prompted to create a new user.
### Starting the Site
With the API running, in a separate terminal run `yarn site:dev`. This will start the front-end Next.js app on `localhost:8000`
## About the codebase
The Keystone and Next.js app are colocated in the same repo for ease of demonstration, but you'd often separate them into different packages in a monorepo or even separate repositories.
The back-end files include:
```
keystone.ts
schema.graphql (generated)
schema.prisma (generated)
schema.ts
schema/*
```
The front-end files include:
```
components/*
pages/*
next-env.d.ts
next.config.js
postcss.config.js
tailwind.config.js
utils.js
```
## License
Copyright (c) 2021 Thinkmill Labs Pty Ltd. Licensed under the MIT License.
104 changes: 52 additions & 52 deletions keystone.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
import { config } from '@keystone-next/keystone';
import { statelessSessions } from '@keystone-next/keystone/session';
import { createAuth } from '@keystone-next/auth';

import { lists, extendGraphqlSchema } from './schema';
import { rules } from './schema/access';

const dbUrl =
process.env.DATABASE_URL ||
`postgres://${process.env.USER}@localhost/prisma-day-workshop`;

const sessionSecret =
process.env.SESSION_SECERT ||
'iLqbHhm7qwiBNc8KgL4NQ8tD8fFVhNhNqZ2nRdprgnKNjgJHgvitWx6DPoZJpYHa';

const auth = createAuth({
identityField: 'email',
secretField: 'password',
listKey: 'User',
sessionData: `id name role {
canManageContent
canManageUsers
}`,
initFirstItem: {
fields: ['name', 'email', 'password'],
itemData: {
role: {
create: {
name: 'Super User',
canManageContent: true,
canManageUsers: true,
},
},
},
},
});

export default auth.withAuth(
config({
db: {
url: dbUrl,
provider: 'postgresql',
useMigrations: true,
},
ui: { isAccessAllowed: rules.canUseAdminUI },
lists,
session: statelessSessions({
secret: sessionSecret,
}),
extendGraphqlSchema,
})
);
import { config } from '@keystone-next/keystone';
import { statelessSessions } from '@keystone-next/keystone/session';
import { createAuth } from '@keystone-next/auth';
import { lists, extendGraphqlSchema } from './schema';
import { rules } from './schema/access';
const dbUrl =
process.env.DATABASE_URL ||
`postgres://${process.env.USER}@localhost/prisma-day-workshop`;
const sessionSecret =
process.env.SESSION_SECERT ||
'iLqbHhm7qwiBNc8KgL4NQ8tD8fFVhNhNqZ2nRdprgnKNjgJHgvitWx6DPoZJpYHa';
const auth = createAuth({
identityField: 'email',
secretField: 'password',
listKey: 'User',
sessionData: `id name role {
canManageContent
canManageUsers
}`,
initFirstItem: {
fields: ['name', 'email', 'password'],
itemData: {
role: {
create: {
name: 'Super User',
canManageContent: true,
canManageUsers: true,
},
},
},
},
});
export default auth.withAuth(
config({
db: {
url: dbUrl,
provider: 'postgresql',
useMigrations: true,
},
ui: { isAccessAllowed: rules.canUseAdminUI },
lists,
session: statelessSessions({
secret: sessionSecret,
}),
extendGraphqlSchema,
})
);
Loading