Open165 Public Information Anti-Fraud Site is built independently by the public to provide resource for individuals who have been targeted by fraud activities. For more details, please refer to the project proposal: https://g0v.hackmd.io/@mrorz/open165-proposal
This is a Next.js project bootstrapped with c3
.
Setup database using:
npm i
npm run db:migrate -- --local
npm run db:seed
First, run the development server:
npm run dev
Open http://localhost:3000 with your browser to see the result.
The application is deployed to Cloudflare Pages. The deployment is done automatically when a PR is merged to main
branch.
If we want to preview the deployment locally, we can use the following command:
npm run preview
This locally builds and previews application using the Wrangler CLI.
For more details see the @cloudflare/next-on-pages
recommended workflow
# Fetch opendata and update local DB
npm run db:seed
# Fetch opendata and update to remote DB. Add --yes to skip confirmation
npm run db:seed -- --remote
The project uses Cloudflare D1 database. To make changes to the database schema, follow these steps:
- Generate new migration SQL file via
This will generate a new migration file in
npm run gen:migration -- <migration_name>
db/migrations
folder, with auto-generated sequence number and.sql
extension. - Modify the migration file as needed.
- Run the following command to apply migrations:
# Apply to local DB npm run db:migrate -- --local # Apply to remote DB (need to login wrangler first) npm run db:migrate -- --remote
- Update
db/schema.sql
for other devs to see the latest schema.npm run gen:schema
If you are pulling changes from the repository and the database schema has changed, you need to run the following commands
# Update local DB by applying new migrations
npm run db:migrate -- --local
Cloudflare Bindings are what allows you to interact with resources available in the Cloudflare Platform.
After we add or remove bindings from wrangler.toml
, use the following command to update
Typescript types for getRequestContext().env
:
npm run gen:env
-
To use bindings in the preview mode you need to add them to the
pages:preview
script accordingly to thewrangler pages dev
command. For more details see its documentation or the Pages Bindings documentation. -
To use bindings in the deployed application you will need to configure them in the Cloudflare dashboard. For more details see the Pages Bindings documentation.