@storecraft/database-planetscale
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Storecraft Planetscale (cloud mysql) Database support



Official Planetscale (cloud MySql) driver for StoreCraft on any platforms.

npm i @storecraft/database-neon

Setup

  • First, login to your planetscale account.
  • Create a database.
  • Copy the connection string.

usage

import 'dotenv/config';
import http from "node:http";
import { join } from "node:path";
import { homedir } from "node:os";

import { App } from '@storecraft/core'
import { NodePlatform } from '@storecraft/platforms/node';
import { PlanetScale } from '@storecraft/database-planetscale'
import { migrateToLatest } from '@storecraft/database-planetscale/migrate.js'
import { NodeLocalStorage } from '@storecraft/storage-local/node'


const app = new App(
  {
    auth_admins_emails: ['admin@sc.com'],
    auth_secret_access_token: 'auth_secret_access_token',
    auth_secret_refresh_token: 'auth_secret_refresh_token'
  }
)
.withPlatform(new NodePlatform())
.withDatabase(
  new PlanetScale(
    { 
      url: process.env.PLANETSCALE_CONNECTION_URL,
      useSharedConnection: true
    }
  )
)
.withStorage(new NodeLocalStorage(join(homedir(), 'tomer')))

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 <tomer.shalev@gmail.com>

Package Sidebar

Install

npm i @storecraft/database-planetscale

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

10.8 kB

Total Files

9

Last publish

Collaborators

  • hendrixstring