Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/swamp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
data/
22 changes: 22 additions & 0 deletions packages/swamp/example/Dockerfile
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

80?

Copy link
Copy Markdown
Author

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


CMD ["node", "dist/index.js"]
21 changes: 21 additions & 0 deletions packages/swamp/example/package.json
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",

@drx drx Aug 6, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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"
}
}
19 changes: 19 additions & 0 deletions packages/swamp/example/src/index.ts
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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();
14 changes: 14 additions & 0 deletions packages/swamp/example/tsconfig.json
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"
}
}
16 changes: 16 additions & 0 deletions packages/swamp/index.ts
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";
Loading