Skip to content

Commit

Permalink
0.1.2 adds MongoDB support, more databases in future
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamint08 committed Apr 6, 2024
1 parent a3f3861 commit acc47d8
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ Bun.build({
format: 'esm',
target: 'bun',
outdir: './lib',
entrypoints: ['./src'],
entrypoints: ['./src/main'],
minify: {
whitespace: true
},
external: Object.keys(pkg.dependencies)
});

await $`bun x tsc`;
await $`mv lib/index.d.ts lib/src/index.d.ts`;

const { values, positionals } = parseArgs({
args: Bun.argv,
Expand All @@ -39,4 +38,5 @@ const { values, positionals } = parseArgs({
if(values.version) {
pkg.version = values.version;
Bun.write('package.json', JSON.stringify(pkg, null, 2));
console.log(`Updated version to ${values.version}`);
}
Binary file modified bun.lockb
Binary file not shown.
18 changes: 18 additions & 0 deletions lib/instances/mongodb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
declare class Mongo {
private client;
connect(url: string): Promise<void>;
getCollection(db: string, col: string): Promise<any>;
getDatabase(db: string): Promise<any>;
update(db: string, col: string, query: any, update: any): Promise<any>;
insert(db: string, col: string, data: any): Promise<any>;
find(db: string, col: string, query: any): Promise<any[]>;
findOne(db: string, col: string, query: any): Promise<any>;
delete(db: string, col: string, query: any): Promise<any>;
close(): Promise<void>;
}
declare class MongoService {
private static instance;
constructor();
static getInstance(): Mongo;
}
export default MongoService;
13 changes: 8 additions & 5 deletions lib/src/index.d.ts → lib/main/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { SendJSON, Success, Failure, ServerFailure, Redirect, Html } from "./helpers/helper.ts";
import { query } from "./helpers/query.ts";
import { param } from "./helpers/param.ts";
import { SendJSON, Success, Failure, ServerFailure, Redirect, Html } from "../helpers/helper.ts";
import { query } from "../helpers/query.ts";
import { param } from "../helpers/param.ts";
import MongoService from "../instances/mongodb.ts";
declare class ProBun {
private port;
private routes;
private logger;
private mongoUri;
constructor(props: {
port: number;
routes: string;
logger: boolean;
mongoUri?: any;
});
start(): void;
start(): Promise<void>;
definePreMiddleware(middleware: any): void;
definePostMiddleware(middleware: any): void;
}
export { ProBun, SendJSON, Success, Failure, ServerFailure, Redirect, Html, query, param };
export { ProBun, SendJSON, Success, Failure, ServerFailure, Redirect, Html, query, param, MongoService };
2 changes: 2 additions & 0 deletions lib/main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions lib/src/index.js

This file was deleted.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "probun",
"description": "Powerful file-based routing for Bun servers",
"module": "src/index.ts",
"version": "0.1.1",
"main": "./lib/src/index.js",
"module": "src/main/index.ts",
"version": "0.1.2",
"main": "./lib/main/index.js",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
Expand All @@ -15,6 +15,7 @@
"build": "bun build.ts"
},
"dependencies": {
"chalk": "^5.3.0"
"chalk": "^5.3.0",
"mongodb": "^6.5.0"
}
}
Loading

0 comments on commit acc47d8

Please sign in to comment.