etf-core v0.1.17
Express Typescript Framework
This is a framework built using Express and Typescript to provide an API server for SQL types of DBs which can be used together with each other. This is a dynamic server to provide instant API's based on models. The focus of this is to provide all the following API's by execution of a command. The server primarily runs on NodeJS along with ExpressTS.
The project is divided into 2 Libraries etf-cli and etf-core
All the apis will have a prefix of their collection / table names or as per user assigned name.
Installation
Install with npm
npm i etf-cli -g
etf -n <projectName>
cd <projectName>
npm iSettings to be done before start of the server -
- Configure your database connection in dbConfig.json
- Configure your secretandrefreshkeys in/src/middlewares/validateToken.ts.
Settings to be done while creating or updating models
- To change the fields or their properties you need to alter the .struct.json file present within the "/src/modules/" Note - The models.ts file is auto generated when the project is served so do not alter that. 
- model.ts files can be rebuilt by running - etf --make or etf -min the project root folder.
API's Provided
- /count (GET)- Return count of entries for specific Table / Collection
- /:id (GET)- Return Specific Entry based on- idor- _idof the item present in collection
- / (GET)- Return List of Entries which have- is_active=True
- / (POST)- Create a new Entry
- /multiple (POST)- Create multiple new entries for same collection
- /:id (PUT)- Update a single entry based on- idor- _id
- /multiple (PUT)- Update multiple entires for same collection
- /:id (DELETE)- Delete single entry based on- idor- _id
- / (DELETE)- Delete multiple entries for same collection
- /short-listing (GET)- Return list of- Key Value Pairsfor the collection with all the entries(PENDING)
- /upload- Upload files respective to the Module and- idor- _id(PENDING)
Notes
- is_activewill define if a entry is deleted or not
- In real no entry is deleted from DB and only is_activeis set toFalse
- By default / (GET)will return specific entries based on the pagination provided
- The (objects for collection / columns for table / keys for the items) will be created inside the models file available for each (module / table / collection). Module in this case is the file structure created by the API Server
/count (GET)
This will return a single object belonging to the following interface
interface Count{    
    code: 200|400|401;
    message: string;
    count: number;
}/:id (GET)
This will return a single object belonging to the Model of the Collection where is_active=True inside an object belonging to following interface
interface GetSpecific{
    code: 200|400|404|401;
    message: string;
    data: CollectionModel|{}
}/ (GET)
This will return multiple objects of the collection in a pagination object belonging to the PaginationResponse interface
export interface MetaColumn {
  name: string;
  type:
    | "_id"
    | "text"
    | "number"
    | "bool"
    | "email"
    | "url"
    | "datetime"
    | "select"
    | "json"
    | "file"
    | "relation";
  displayName?: string;
  sorting: boolean;
  sortingOrder: boolean;
  visible: boolean;
}
interface PaginationResponse{
    code: 200|400|401;
    message: string;
    data: {
        meta: {
            columns: MetaColumn[]
            pagination: {
                page: number;
                pageSize: number;
                pageCount: number;
                total: number;
            };
        },
        rows: CollectionModel[]
    }
}This API can also take the following request params | path params
- nested=1|0;
- page: number;
- page_size: number;
- order_by: ColumnName|ObjectKey;
- order: 'ASC'|'DESC'
Note - the keys visible in the response can be configured on the Server Side
/ (POST)
This will create a single entry in the collection | table and will return response belonging to following interface
interface PostSingle{
    code: 200|400|401;
    message: string;
    data: createdObject;
}/multiple (POST)
This will create multiple entries belonging to same collection | table and will return response belonging to following interface
interface PostMultiple{
    code: 200|400|401;
    message: string;
    data: createdObject[];
}/:id (PUT)
This will update a single entry and will return response belonging to following interface
interface PutSingle{
    code: 200|400|401;
    message: string;
    data: updatedObject;
}/multiple (PUT)
This will update entries belonging to same collection | table and will return response belonging to following interface
interface PutMultiple{
    code: 200|400|401;
    message: string;
    data: updatedObject[];
}/:id (DELETE)
This will delete a single entry and will return response belonging to following interface
interface DeleteSingle{
    code: 200|400|401;
    message: string;
    data: deletedObjectId;
}/multiple (DELETE)
This will delete entries belonging to same collection | table and will return response belonging to following interface
interface PutMultiple{
    code: 200|400|401;
    message: string;
    data: deletedObjectId[];
}/short-listing (GET)
Return list of Key Value Pairs for the collection with all the entries belonging to following interface
interface KeyValuePair{
    name: string;
    value: number;
}
interface ShortListing{
    code: 200|400|401;
    message: string;
    data: KeyValuePair[];
}Note name and value inside KeyValuePair needs to be configured on server side.
Authors
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago