-
Notifications
You must be signed in to change notification settings - Fork 0
Init Swamp #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Init Swamp #3
Changes from all commits
e342fcd
51cfec6
ba5548b
4cc2f06
c6058ca
2dde77c
b749414
8e045d1
8b44180
dd3c3b5
a6e6bd4
f867260
3675be4
3faa1f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| node_modules/ | ||
| dist/ | ||
| data/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| FROM node:18 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ENV PORT=80 | ||
|
|
||
| COPY package*.json ./ | ||
|
|
||
| RUN npm install && npm install typescript -g | ||
|
|
||
| COPY src ./src | ||
| COPY tsconfig.json ./ | ||
|
|
||
| # this must go after install or else dev deps will be ignored | ||
| ENV NODE_ENV=production | ||
|
|
||
| RUN npm run build | ||
|
|
||
| # Expose the port the app runs on | ||
| EXPOSE 80 | ||
|
|
||
| CMD ["node", "dist/index.js"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "name": "swamp-example", | ||
| "version": "1.0.0", | ||
| "main": "src/index.ts", | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "HACK-comment": "TZ=UTC is necessary because SQLite will not respect system timezone", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems "//" is "idiomatic" https://stackoverflow.com/questions/14221579/how-do-i-add-comments-to-package-json-for-npm-install
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clever |
||
| "dev": "TZ=UTC nodemon src/index.ts" | ||
| }, | ||
| "author": "Infinite Canvas Inc.", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "@canvas-sdk/swamp": "0.1.0", | ||
| "axios": "^1.7.3", | ||
| "neverthrow": "^7.0.0", | ||
| "zod": "^3.23.8" | ||
| }, | ||
| "devDependencies": { | ||
| "nodemon": "^3.1.4" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { | ||
| Swamp, | ||
| InMemoryDuckDb, | ||
| EnvVarSecretStore, | ||
| runPostgres, | ||
| SQLiteStore, | ||
| } from "@canvas-sdk/swamp"; | ||
|
|
||
| export function syncPostgres(): Swamp { | ||
| const metaStore = new EnvVarSecretStore(); | ||
| const store = new SQLiteStore("local.db"); | ||
| const sqlEngine = new InMemoryDuckDb(store); | ||
| const swamp = new Swamp(store, metaStore, sqlEngine); | ||
| swamp.initialize(); | ||
| swamp.addLoader(runPostgres, "postgres").withCadence(60 * 60); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Adding naive questions from my first reading to reveal non-obvious names) What's cadence? |
||
| return swamp; | ||
| } | ||
|
|
||
| syncPostgres(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "outDir": "dist", | ||
| "sourceMap": true, | ||
| "target": "esnext", | ||
| "module": "commonjs", | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "noImplicitAny": true, | ||
| "strict": true, | ||
| "skipLibCheck": true, | ||
| "moduleResolution": "node" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| export { Swamp } from "./src/core/core"; | ||
| export { | ||
| LoaderResponse, | ||
| LoaderSecrets, | ||
| LoaderInserts, | ||
| Inserts, | ||
| } from "./src/core/types"; | ||
| export { DuckDbEngine as InMemoryDuckDb } from "./src/query/query"; | ||
| export { | ||
| EnvVarSecretStore, | ||
| YamlFileSecretStore, | ||
| } from "./src/secrets/secret.store"; | ||
| export { SQLiteStore, S3SQLiteStore } from "./src/store/sqlite.store"; | ||
| export { runPostgres } from "./src/connectors/postgres"; | ||
| export { SwampBuilder } from "./src/core/core"; | ||
| export { TransformSQL, TransformSQLResult } from "./src/core/types"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
80?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just has to match
ENV PORT=...above; can add comment