├── .gitignore ├── README.md ├── components └── Layout.tsx ├── next-env.d.ts ├── package.json ├── pages ├── data │ └── [schema] │ │ └── [seed].tsx └── index.tsx ├── public └── _redirects ├── tsconfig.json ├── utils ├── columnsToFakeInserts.ts ├── generateInsertStatements.ts ├── isBrowser.ts └── parseSchema.ts └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .next 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | code for [https://postgres-fake-data.netlify.com/](https://postgres-fake-data.netlify.com/) 2 | -------------------------------------------------------------------------------- /components/Layout.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import Head from "next/head"; 3 | 4 | type Props = { 5 | title?: string; 6 | }; 7 | 8 | const Layout: React.FunctionComponent = ({ 9 | children, 10 | title = "This is the default title" 11 | }) => ( 12 |
13 | 14 | {title} 15 | 16 | 17 | 18 | {children} 19 |
20 | ); 21 | 22 | export default Layout; 23 | -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-typescript", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start", 8 | "export": "next export", 9 | "type-check": "tsc" 10 | }, 11 | "dependencies": { 12 | "faker": "^4.1.0", 13 | "isomorphic-unfetch": "3.0.0", 14 | "next": "latest", 15 | "react": "^16.12.0", 16 | "react-dom": "^16.12.0" 17 | }, 18 | "devDependencies": { 19 | "@types/faker": "^4.1.9", 20 | "@types/node": "^12.12.21", 21 | "@types/react": "^16.9.16", 22 | "@types/react-dom": "^16.9.4", 23 | "typescript": "3.7.3" 24 | }, 25 | "license": "ISC" 26 | } 27 | -------------------------------------------------------------------------------- /pages/data/[schema]/[seed].tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Layout from "../../../components/Layout"; 3 | import { NextPage } from "next"; 4 | import { generateInsertStatements } from "../../../utils/generateInsertStatements"; 5 | import { isBrowser } from "../../../utils/isBrowser"; 6 | import { withRouter } from "next/router"; 7 | 8 | const DataGenerator: NextPage = ({ router }: any) => { 9 | const { schema, seed } = router.query; 10 | if (!isBrowser()) { 11 | return null; 12 | } 13 | 14 | const statements = generateInsertStatements(schema, seed); 15 | 16 | return ( 17 | 18 |
24 |         {Array.isArray(statements) ? statements.join("\n") : statements}
25 |       
26 |
27 | ); 28 | }; 29 | 30 | export default withRouter(DataGenerator); 31 | -------------------------------------------------------------------------------- /pages/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import Layout from "../components/Layout"; 3 | import { NextPage } from "next"; 4 | import Router from "next/router"; 5 | import { parseSchema } from "../utils/parseSchema"; 6 | 7 | const IndexPage: NextPage = () => { 8 | const [text, setText] = React.useState(); 9 | const [error, setError] = React.useState(""); 10 | 11 | return ( 12 | 13 |
14 |

Generate Fake Data for your PostgreSQL Database

15 |

16 | click here for tutorial data 17 |

18 |
Supported data types:
19 | 30 |

paste tables below.

31 |
32 |