Freedom of Information modernization
Are you a user looking to publish an article? Check our simple docs/publishing-an-article.md step by step instructions.
- Static-Site Generation. All Help articles are generated once as build-time, so the site is performant and frontend users never wind up querying the Strapi backend.
- Secure. By never exposing the Strapi backend to anything besides our build-time frontend, we ensure it's isolated from citizens and less exposed.
First, setup the DB.
docker-compose up -dStrapi must be setup first, as the frontend (NextJS) depends upon it.
cd backend/
yarn install
yarn developOnce Strapi is setup, go and create a read only API token.
- Login to Strapi, create initial admin user.
- Create API Token in Strapi for NextJS to consume
- In Strapi: Settings > API Tokens > Create New API Token
- Name: read-help
- Token type: read-only
- Make sure to copy the token down! You will not be able to view it later. If you lose the token, you must delete and re-do step #2.
- Put in
frontend/.envasSTRAPI_READ_TOKEN, and also setSTRAPI_READ_TOKENas the same base URL you logged into for step #1.
# example frontend/.env
STRAPI_READ_TOKEN=long_token_here
STRAPI_API_URL=http://localhost:1337cd frontend/
yarn install
yarn devcd backend/
yarn build
yarn start
# in another terminal, only after above is complete
cd frontend/
yarn build
yarn startHow is this different from running yarn develop / yarn dev?
- backend: Server's custom types are in read-only mode, cannot add new fields to models.
- backend: Server is faster
- frontend: All frontend pages are built-up front during
yarn build, and then served duringyarn start. In contrast in dev, a page is built per load. - frontend: This is a LOT faster at generating pages, BUT any changes you make in Strapi require a whole new rebuild.
In short, using yarn build / start is what we use in OpenShift, it is faster and more performant for end users, but more of a pain for developers. Generally when you do development you will just use the development options as it's more convenient. You can use the above to test OpenShift builds should work locally, and to measure performance differences.
The project is in the very early stages of development. The codebase will be changing frequently.
To report bugs/issues/feature requests, please file an issue.
If you would like to contribute, please see our contributing guidelines. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Copyright 2021 Province of British Columbia
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.