@storecraft/database-neon
v1.0.4
Published
`Storecraft` database driver for `Neon` over http
Downloads
196
Maintainers
Readme
Storecraft Neon (cloud postgres) Database support
Official Neon
driver for StoreCraft
on any platforms.
npm i @storecraft/database-neon
Setup
- First, login to your neon account account.
- Create a database.
- Copy the
connection string
.
usage
import 'dotenv/config';
import http from "node:http";
import { App } from '@storecraft/core'
import { NodePlatform } from '@storecraft/core/platform/node';
import { NeonHttp } from '@storecraft/database-neon'
import { NodeLocalStorage } from '@storecraft/core/storage/node'
import { migrateToLatest } from '@storecraft/database-neon/migrate.js'
const app = new App(
{
auth_admins_emails: ['[email protected]'],
auth_secret_access_token: 'auth_secret_access_token',
auth_secret_refresh_token: 'auth_secret_refresh_token'
}
)
.withPlatform(new NodePlatform())
.withDatabase(
new NeonHttp(
{
connectionString: process.env.NEON_CONNECTION_URL
}
)
)
.withStorage(new NodeLocalStorage('storage'))
await app.init();
await migrateToLatest(app.db, false)
const server = http.createServer(app.handler).listen(
8000,
() => {
console.log(`Server is running on http://localhost:8000`);
}
);
Author: Tomer Shalev <[email protected]>