Skip to content
/ site Public

Displays contents in 165 反詐騙 opendata in a search-engine friendly way

License

Notifications You must be signed in to change notification settings

Open165/site

Repository files navigation

Open165 Anti-Fraud Information Site

CI test

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.

First-time setup

Setup database using:

npm i
npm run db:migrate -- --local
npm run db:seed

Start server

First, run the development server:

npm run dev

Open http://localhost:3000 with your browser to see the result.

Deploy

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

Updating scam site DB from 165 open data

# 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

Making changes to the database schema

The project uses Cloudflare D1 database. To make changes to the database schema, follow these steps:

  1. Generate new migration SQL file via
    npm run gen:migration -- <migration_name>
    This will generate a new migration file in db/migrations folder, with auto-generated sequence number and .sql extension.
  2. Modify the migration file as needed.
  3. 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
  4. Update db/schema.sql for other devs to see the latest schema.
    npm run gen:schema

Incorporating other's changes to the database 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

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
Details of Cloudflare bindings - During development, `setupDevPlatform` from `@cloudflare/next-on-pages` is called to setup bindings for you. This function is called in the `next.config.mjs`.

About

Displays contents in 165 反詐騙 opendata in a search-engine friendly way

Topics

Resources

License

Stars

Watchers

Forks