Open devuxer opened 7 years ago
I had a little time today to create a typescript declaration (d.ts file) for epilogue. I'm not savvy enough yet to know how to turn this into a proper @types/epilogue NPM package, but I thought I'd post what I have for the moment in case it helps others:
declare module "epilogue" {
import { Express } from "express";
import { Sequelize } from "sequelize-typescript";
function initialize(options: initializeOptions): void;
function resource(options: resourceOptions): void;
interface initializeOptions {
app: Express;
sequelize: Sequelize;
base?: string;
updateMethod?: "POST" | "PUT" | "PATCH";
}
interface resourceOptions {
app?: Express;
sequelize?: Sequelize;
model: any;
endpoints?: string[];
actions?: Array<"create" | "read" | "update" | "delete" | "list">;
include?: any[];
pagination?: boolean;
updateMethod?: "POST" | "PUT" | "PATCH";
search?: searchOptions | searchOptions[];
sort?: sortOptions;
reloadInstances?: boolean;
associations?: boolean;
excludeAttributes?: string[];
readOnlyAttributes?: string[];
}
interface searchOptions {
operator: "$like" | "$ilike" | "$iLike" | "$notLike" | "$notILike" | "$ne" | "$eq" | "$not" | "$gte" | "$gt" | "$lte" | "$lt";
param: string;
attributes: string[];
}
interface sortOptions {
param: string;
attributes: string[];
default: string;
}
}
I have copied @devuxer's work and create a more sophisticated version here:
https://gist.github.com/linktohack/e4178333565b70f6e0c18581a6b0a063
If it's okay I'd like to contribute back to epilogue
(create a typing section) rather than create a new @types
package.
@linktohack , Looks great! Thanks!
Pull request added, please discuss the rest there https://github.com/dchester/epilogue/pull/218
Just wondering if anyone has created typescript typings for this project. I was surprised such a popular library didn't have a
@types/epilogue
package on npm.