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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@trabpukcip/godsmack

v0.0.6-alpha.17

Published

Application framework for dummies

Downloads

4

Readme

Godsmack

Application framework for dummies

Usage

Step 1

  • Install @trabpukcip/godsmack package
yarn global add @trabpukcip/godsmack

Step 2

  • Initialize a new project
~/ $ mkdir new-project
~/ $ cd new-project
~/new-project $ gs-init
✔ Project Name · new-project
✔ Project Version · 0.0.1
✔ Project License · MIT
✔ Add Docker Support? (y/N) · false
✔ Add Docker Database Support? (y/N) · true
✔ Add Postgres Database Support? (y/N) · true
✔ Base directory for server code? · server
✔ Generating Directories
✔ Installing Dependencies
~/new-project $

Step 3

  • Configure Application (Example shown)

File: <server_root>/app.ts

import {
  ApplicationBuilder,
  DatabaseProvider,
  HttpServerProvider,
  LogFactory,
  TaskService,
 } from "@trabpukcip/godsmack";

// not shown
import { ErrorMiddleware } from "./middleware/error";
// not shown
import { defaultSettings } from './settings';

// -- Application Specific Setup
export default ApplicationBuilder.Create({
  ConfigureServices: container => container
    .addSingleton(LogFactory)
  ,
  ConfigureDatabase: app => app
    .addTypeORMPostgresDB()
  ,
  ConfigureServer: app => app
    .addExpressServer()
    .useHelmet()
    .useHealthCheck()
    .parseCookies()
    .parseJsonBody()
    .serveStaticFiles()
    .useJwtExpress()
    .useSpaFallback()
    .useErrorHandler(ErrorMiddleware)
  ,
}).configure(app => app
  .useSettings(defaultSettings)
  .addCronTriggers()
  .addSwaggerDocs()
  .addTypeGraphQl()
  .addHotSwapping()
  .usePrettyConsoleErrors()

  // -- Business Logic
  .onAppStarted(async () => {

    const database = app.container
      .resolve(DatabaseProvider)

    const server = app.container
      .resolve(HttpServerProvider)

    const tasks = app.container
      .resolve(TaskService)

    await database.connect()
    await database.test()
    await database.syncTables()

    await tasks.startAll()

    await server.listen()
  })
)

Example Services

Controllers

File: <server_root>/controllers/Reaction.ts


import { Body, http, Singleton, LogFactory } from '@trabpukcip/godsmack';
import {
  Controller,
  Post,
  Request,
  Response,
  Route,
  Security,
  SuccessResponse,
  Tags,
} from 'tsoa';
import { GetTypeIdModel } from '../DTOs/request.dto';
import { ReactionsService } from '../services/reactions';
import { SecureRequest } from '../types';
const { StatusCode } = http;

@Route('reaction')
@Tags('reaction')
@Singleton()
export class ReactionController extends Controller {
  constructor(
    private logger: LogFactory,
    private reactions: ReactionsService,
  ) {
    super()
    this.logger = logger.For(this)
  }

  /**
   * Register a Users reaction to something (WIP)
   *
   * @description UserReaction endpoint.
   * @summary Create a new User Reaction
   *
   * @param {string} userId
   * @param {GetTypeIdModel} requestBody
   *
   */
  @Security('jwt')
  @Security('apiKey')
  @Response(StatusCode.UNPROCESSABLE_ENTITY, "Validation Failed")
  @SuccessResponse(StatusCode.CREATED, "Created")
  @Post('/')
  public async createReaction(
    @Body() requestBody: GetTypeIdModel,
    @Request() { req }: SecureRequest,
  ): Promise<void> {
    this.setStatus(201)

    await this.reactions.createUserReaction(
      req.user.userId,
      requestBody.typeId,
    )
  }
}

File: <server_root>/app.ts

import {
  ApplicationBuilder,
  HttpServerProvider,
  LogFactory,
 } from "@trabpukcip/godsmack";

export default ApplicationBuilder.Create({
  ConfigureServices: container => container
    .addSingleton(LogFactory)
  ,
  ConfigureServer: app => app
    .addExpressServer()
    .parseJsonBody()
  ,
}).configure(app => app
  .addSwaggerDocs()             // <- This right here
  .onAppStarted(async () => {

    const server = app.container
      .resolve(HttpServerProvider)

    await server.listen()
  })
)

Tasks

File: <server_root>/jobs/VacuumDB.ts


import {
  ICronTrigger,
  DatabaseProvider,
  Singleton,
  LogFactory,
} from '@trabpukcip/godsmack'

@Singleton()
export class VacuumDatabaseJob implements ICronTrigger {
  constructor(
    public logger: LogFactory,
    public db: DatabaseProvider,
  ) {
    this.logger = logger.For(this)
  }

  public onTick = async (): Promise<void> => {
    this.logger.info('Vacuuming Database.')
    await this.db.query('VACUUM;')
    this.logger.info('Vacuum Complete.')
  }

  public readonly cronTime: string = "0 22 * * * *"
}

File: <server_root>/app.ts

import {
  ApplicationBuilder,
  HttpServerProvider,
  LogFactory,
 } from "@trabpukcip/godsmack";

export default ApplicationBuilder.Create({
  ConfigureServices: container => container
    .addSingleton(LogFactory)
  ,
  ConfigureServer: app => app
    .addExpressServer()
  ,
}).configure(app => app
  .addCronTriggers()             // <- This right here
  .onAppStarted(async () => {

    const server = app.container
      .resolve(HttpServerProvider)

    const tasks = app.container
      .resolve(TaskService)

    await tasks.startAll()

    await server.listen()
  })
)

License

  • MIT