@storecraft/platforms
v1.0.2
Published
Official platforms adapters for storecraft
Downloads
205
Maintainers
Readme
Storecraft Node.js Platform support
So, if you wanted to run StoreCraft
on the following platforms,
- Node.js
- Deno
- Bun
- Cloudflare Workers
- Google Functions
- Azure Functions
- AWS Lambda Functions (with API Gateway)
- Vercel Platform
What does it do exactly ?
Basically,
- Translates incoming messages into web Request
- Translates outgoing messages into web Response
- Exposes
environmant
variables - Adds helpers
npm i @storecraft/platforms
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 { MongoDB } from '@storecraft/database-mongodb-node'
import { NodeLocalStorage } from '@storecraft/storage-local/node'
const app = new App(
config
)
.withPlatform(new NodePlatform())
.withDatabase(new MongoDB())
.withStorage(new NodeLocalStorage(join(homedir(), 'tomer')))
await app.init();
const server = http.createServer(app.handler).listen(
8000,
() => {
console.log(`Server is running on http://localhost:8000`);
}
);
Author: Tomer Shalev ([email protected])