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

Update redwood / Add Docker / Fix Scraper #13

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
.env
.netlify
dev.db
dev.db*
dist
dist-babel
node_modules
Expand Down
9 changes: 9 additions & 0 deletions .redwood/globals/routes-globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type FatalErrorPageType from '/Users/delong/dev/covid19/web/src/pages/FatalErrorPage/FatalErrorPage'
import type HomePageType from '/Users/delong/dev/covid19/web/src/pages/HomePage/HomePage'
import type NotFoundPageType from '/Users/delong/dev/covid19/web/src/pages/NotFoundPage/NotFoundPage'

declare global {
const FatalErrorPage: typeof FatalErrorPageType
const HomePage: typeof HomePageType
const NotFoundPage: typeof NotFoundPageType
}
5 changes: 5 additions & 0 deletions .redwood/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 2021-05-12T04:31:24.310Z
/// <reference path="./types/currentUser.d.ts" />
/// <reference path="./types/import-dir-schemas.d.ts" />
/// <reference path="./types/import-dir-services.d.ts" />
/// <reference path="./types/routes.d.ts" />
17 changes: 17 additions & 0 deletions .redwood/types/currentUser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import '@redwoodjs/api'
import '@redwoodjs/auth'

import { getCurrentUser } from '../../api/src/lib/auth'

type ThenArg<T> = T extends PromiseLike<infer U> ? U : T
export type InferredCurrentUser = ThenArg<ReturnType<typeof getCurrentUser>>

declare module '@redwoodjs/api' {
interface GlobalContext {
currentUser?: InferredCurrentUser
}
}

declare module '@redwoodjs/auth' {
interface CurrentUser extends InferredCurrentUser {}
}
2 changes: 2 additions & 0 deletions .redwood/types/import-dir-schemas.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @ts-expect-error
declare module 'src/graphql/**/*.{js,ts}';
2 changes: 2 additions & 0 deletions .redwood/types/import-dir-services.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @ts-expect-error
declare module 'src/services/**/*.{js,ts}';
11 changes: 11 additions & 0 deletions .redwood/types/routes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import '@redwoodjs/router'

type ParamType<constraint> = constraint extends "Int" ? number : constraint extends "Boolean" ? boolean : constraint extends "Float" ? number : string;
type RouteParams<Route> = Route extends `${string}/{${infer Param}:${infer Constraint}}/${infer Rest}` ? { [Entry in Param]: ParamType<Constraint> } & RouteParams<`/${Rest}`> : Route extends `${string}/{${infer Param}:${infer Constraint}}` ? { [Entry in Param]: ParamType<Constraint> } : Route extends `${string}/{${infer Param}}/${infer Rest}` ? { [Entry in Param]: string } & RouteParams<`/${Rest}`> : {}
type QueryParams = Record<string | number, string | number | boolean>

declare module '@redwoodjs/router' {
interface AvailableRoutes {
home: (params?: RouteParams<"/"> & QueryParams) => "/"
}
}
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,44 @@ We use Yarn as our package manager. To get the dependencies installed, just do t
yarn
```

### Fire it up
### Initialize Database

```terminal
yarn redwood dev
```
We’re using [Prisma2](https://github.com/prisma/prisma2), a modern DB toolkit to query, migrate and model your database.

Your browser should open automatically to `http://localhost:8910` to see the web app. Lambda functions run on
`http://localhost:8911` and are also proxied to `http://localhost:8910/api/functions/*`.
Prisma2 is [ready for production](https://isprisma2ready.com).

But we don’t have any data, or even a database!
To create a development database:

### Database
1. Change `./api/prisma/schema.prisma` to use `"sqlite"`:

We’re using [Prisma2](https://github.com/prisma/prisma2), a modern DB toolkit to query, migrate and model your database.
```prisma
datasource DS {
provider = "sqlite"
url = env("DATABASE_URL")
}
```

Prisma2 is [not ready for production](https://isprisma2ready.com) at the moment.
2. Then run `yarn redwood prisma migrate dev`

To create a development database:
This will read the schema definition in `api/prisma/schema.prisma` and generate a SQLite database in `api/prisma/dev.db`

### Fire it up

```terminal
yarn redwood db up
yarn redwood dev
```

This will read the schema definition in `api/prisma/schema.prisma` and generate a SQLite database in `api/prisma/dev.db`
Your browser should open automatically to `http://localhost:8910` to see the web app. Lambda functions run on
`http://localhost:8911` and are also proxied to `http://localhost:8910/api/functions/*`.

(If you’ve made changes to the schema run `yarn redwood db save` to generate a migration, and `yarn redwood db up`
to apply the migration/generate a new ORM client.)
But we don’t have any data!

### Downloading data

First, seed the database:

```terminal
yarn redwood db seed
yarn redwood prisma db seed
```

Now, run the scraper. In one terminal, start the server (`yarn rw dev`), and in another, make this request:
Expand All @@ -73,8 +77,8 @@ curl http://localhost:8911/scrape

You should be good to go now! Open [localhost:8910](http://localhost:8910) & enjoy development.

***
---

*Thanks to [dDara](https://thenounproject.com/dDara/) for [the icon](https://thenounproject.com/dDara/collection/coronavirus/).*
_Thanks to [dDara](https://thenounproject.com/dDara/) for [the icon](https://thenounproject.com/dDara/collection/coronavirus/)._

MIT License
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"@redwoodjs/api": "^0.2.4",
"@redwoodjs/api": "^0.31.2",
"apollo-server-plugin-response-cache": "^0.4.0",
"cheerio": "^1.0.0-rc.3",
"isomorphic-unfetch": "^3.0.0"
Expand Down

This file was deleted.

This file was deleted.

Loading