delete package.json

This commit is contained in:
Ozum
2018-05-19 12:52:04 +03:00
parent 0496d0f94f
commit 48fc5d3017
5 changed files with 11 additions and 95 deletions

View File

@@ -1,83 +0,0 @@
// Type definitions for schwifty 4.0.
// Project: https://github.com/hapipal/schwifty
// Definitions by: ozum <https://github.com/ozum>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
// HELP WANTED: If possible, find a better way to define Server.models, Request.models and ResponseToolkit.models
// They are dynamic types extended from SchwiftyModel.
import * as Objection from "objection";
import * as Joi from "joi";
import {
Server,
Request,
ResponseToolkit,
Plugin,
ServerRegisterPluginObject
} from "hapi";
import * as Knex from "knex";
type Model = typeof SchwiftyModel | typeof Objection.Model;
declare class SchwiftyModel extends Objection.Model {
static getJoiSchema(patch?: boolean): Joi.Schema;
joiSchema: Joi.Schema;
}
interface RegistrationOptions {
knex?: Knex | Knex.Config;
models?: Array<Model> | string;
migrationsDir?: string;
teardownOnStop?: boolean;
migrateOnStart?: boolean | "latest" | "rollback";
}
interface SchwiftyExtras {
assertCompatible: (
ModelA: typeof SchwiftyModel,
ModelB: typeof SchwiftyModel,
message?: string
) => void | Error;
Model: typeof SchwiftyModel;
}
declare const Schwifty: Plugin<RegistrationOptions> & SchwiftyExtras;
export const plugin: Plugin<RegistrationOptions>;
//export = Schwifty;
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Hapi Decorations +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
/**
* Merge decorations into hapi objects.
*/
declare module "hapi" {
interface Server {
schwifty: (
config:
| Model
| Array<Model>
| {
knex: Knex | Knex.Config;
models: Array<Model>;
migrationsDir: string;
}
) => void;
knex: () => Knex;
models: (all?: boolean) => { [key: string]: typeof SchwiftyModel };
}
interface Request {
knex: () => Knex;
models: (all?: boolean) => { [key: string]: typeof SchwiftyModel };
}
interface ResponseToolkit {
knex: () => Knex;
models: (all?: boolean) => { [key: string]: typeof SchwiftyModel };
}
}

View File

@@ -1,6 +0,0 @@
{
"private": true,
"dependencies": {
"objection": "^1.1.8"
}
}

View File

@@ -1,7 +1,7 @@
import * as Hapi from "hapi";
import * as Joi from "joi";
import * as Schwifty from "schwifty";
import DogClass from "./test/dog";
import DogModel from "./test/dog";
(async () => {
const server = new Hapi.Server({ port: 3000 });
@@ -20,13 +20,13 @@ import DogClass from "./test/dog";
}
});
Schwifty.assertCompatible(DogClass, DogClass);
Schwifty.assertCompatible(DogModel, DogModel);
// Register a model with schwifty...
server.schwifty(DogClass);
server.schwifty(DogModel);
await server.initialize();
const Dog: typeof DogClass = server.models().Dog;
const Dog: typeof DogModel = server.models().Dog;
await Dog.query().insert({ name: "Guinness" });

View File

@@ -5,7 +5,7 @@ import DogModel from "./dog";
exports.plugin = {
register: async (
server: Hapi.Server,
options: { Model: Schwifty.Model }
options: { Model: typeof Schwifty.Model }
) => {
await server.register(Schwifty);

View File

@@ -13,5 +13,10 @@
"target": "es6",
"strictFunctionTypes": true
},
"files": ["index.d.ts", "schwifty-tests.ts"]
"files": [
"index.d.ts",
"schwifty-tests.ts",
"test/dog.ts",
"test/plugin.ts"
]
}