npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

etf-core

v0.1.17

Published

Core for ETF which is a framework for API using Express, Typescript and PostgreSQL

Downloads

30

Readme

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 i

Settings to be done before start of the server -

  • Configure your database connection in dbConfig.json
  • Configure your secret and refresh keys 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 -m in the project root folder.

API's Provided

  • /count (GET) - Return count of entries for specific Table / Collection
  • /:id (GET) - Return Specific Entry based on id or _id of 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 id or _id
  • /multiple (PUT) - Update multiple entires for same collection
  • /:id (DELETE) - Delete single entry based on id or _id
  • / (DELETE) - Delete multiple entries for same collection
  • /short-listing (GET) - Return list of Key Value Pairs for the collection with all the entries(PENDING)
  • /upload - Upload files respective to the Module and id or _id (PENDING)

Notes

  • is_active will define if a entry is deleted or not
  • In real no entry is deleted from DB and only is_active is set to False
  • 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