Skip to content

Commit

Permalink
[web] Add Privacy Policy and TOS pages (kriasoft#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
koistya authored Mar 1, 2021
1 parent 9d7f8da commit 6c81f2d
Show file tree
Hide file tree
Showing 12 changed files with 598 additions and 6 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"cSpell.ignoreWords": [
"abcdefghijklmnopqrstuvwxyz",
"browserslist",
"cloudfunctions",
"cloudsql",
"corejs",
Expand Down
10 changes: 10 additions & 0 deletions db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ $ yarn db:restore [--env #0] [--from #0]

You can find backup files inside of the [`/backups`](./backups) folder.

## How to generate seed files

Generate seed files by using Faker.js (see [`/seeds/*.js`](./seeds)).
Alternatively, fetch the actual data from the database and save it into JSON
files as seeds by running:

```
$ yarn db:import-seeds [--env #0]
```

## References

- [Knex.js Migration API](https://knexjs.org/#Migrations-API)
Expand Down
2 changes: 2 additions & 0 deletions db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"seed": "knex seed:run",
"reset": "node ./scripts/reset",
"backup": "node ./scripts/backup",
"import-seeds": "node ./scripts/import-seeds",
"restore": "node ./scripts/restore",
"update-types": "node ./scripts/update-types",
"repl": "node --experimental-repl-await ./scripts/repl",
Expand All @@ -24,6 +25,7 @@
"db:seed": "yarn workspace db seed",
"db:reset": "yarn workspace db reset",
"db:backup": "yarn workspace db backup",
"db:import-seeds": "yarn workspace db import-seeds",
"db:restore": "yarn workspace db restore",
"db:update-types": "yarn workspace db update-types",
"db:repl": "yarn workspace db repl",
Expand Down
36 changes: 36 additions & 0 deletions db/scripts/import-seeds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Imports reference (seed) data from the database.
*
* yarn db:import-seeds [--env #0]
*
* @copyright 2016-present Kriasoft (https://git.io/Jt7GM)
*/

require("env");
const fs = require("fs");
const path = require("path");
const prettier = require("prettier");
const db = require("knex")(require("../knexfile"));

function saveSync(filename, data) {
fs.writeFileSync(
path.resolve(__dirname, filename),
prettier.format(JSON.stringify(data), { parser: "json" }),
"utf-8",
);
}

async function importData() {
const users = await db.table("user").orderBy("created_at").select();
saveSync("../seeds/01_users.json", users);

const identities = await db.table("identity").orderBy("created_at").select();
saveSync("../seeds/02_identities.json", identities);
}

importData()
.finally(() => db.destroy())
.catch((err) => {
console.error(err);
process.exit(1);
});
1 change: 1 addition & 0 deletions db/scripts/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async function reset() {
// Drop and re-create the database
await db.raw(`DROP DATABASE IF EXISTS ??`, [process.env.PGDATABASE]);
await db.raw(`CREATE DATABASE ??`, [process.env.PGDATABASE]);
await new Promise((resolve) => setTimeout(resolve, 1000));
await db.destroy();

// Migrate database to the latest version
Expand Down
2 changes: 1 addition & 1 deletion web/core/router.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type Route<
/**
* GraphQL query expression.
*/
query: GraphQLTaggedNode;
query?: GraphQLTaggedNode;
/**
* GraphQL query variables.
*/
Expand Down
3 changes: 2 additions & 1 deletion web/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import home from "./home";
import account from "./account";
import legal from "./legal";
import user from "./user";

/**
* The list of application routes (pages).
*/
export default [home, account, user] as const;
export default [home, account, ...legal, user] as const;
Loading

0 comments on commit 6c81f2d

Please sign in to comment.