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

@athenajs/core

v1.3.2

Published

![NPM version badge](https://img.shields.io/npm/v/@athenajs/core) ![Core workflow status badge](https://github.com/aldahick/athena/actions/workflows/core.yml/badge.svg?branch=main) ![Demo workflow status badge](https://github.com/aldahick/athena/actions/w

Downloads

454

Readme

athena

NPM version badge Core workflow status badge Demo workflow status badge React Utils workflow status badge Utils workflow status badge

A modular backend framework atop Apollo and Fastify. Simpler and more opinionated than its inspiration, Nest.

If you're curious about recent changes, please see the changelog.

Features

To Do

Getting Started

Install dependencies:

npm install --save @athenajs/core reflect-metadata
npm install --save-dev @types/node typescript

Make sure your tsconfig has "experimentalDecorators": true and "emitDecoratorMetadata": true. To use ES modules, either set "type": "module" in your package.json, or name your files .mts instead of .ts.

Instantiate and start the server:

import "reflect-metadata";
import { createApp } from "@athenajs/core";
import "./config.js";
import "./hello-resolver.js";

const app = createApp();
await app.start();

Since Athena relies on dependency injection rather heavily, you accomplish configuration by extending BaseConfig. The following code is the same ./config.js imported above. (Note the additional dependency on @athenajs/utils, for convenience's sake.)

import { BaseConfig, config } from "@athenajs/core";
import { getModuleDir } from "@athenajs/utils";
import { resolve } from "path";

@config()
export class Config extends BaseConfig {
  // for example, to specify the directories containing your GQL schema, override like so:
  readonly graphqlSchemaDirs = [resolve(getModuleDir(import.meta), "../schema")];
  // or, for new fields altogether, you can use this.optional & this.required to read/verify environment variables
  readonly databaseUrl: string = this.required("DATABASE_URL");
  readonly environment: string | undefined = this.optional("NODE_ENV");
}

It's simple to inject dependencies into constructors, thanks to tsyringe. Writing resolvers is just as straightforward:

/**
 * resolves for the following schema:
 * type Query {
 *   hello: String!
 * }
 */
import { resolver } from "@athenajs/core";
import { Config } from "./config.js";

@resolver()
export class HelloResolver {
  // inject dependencies by including them as constructor params
  constructor(private config: Config) { }

  @resolveQuery()
  async hello(): Promise<string> {
    return "Hello, world!";
  }

  // If you don't want to name your methods after the fields they resolve, don't!
  @resolveField("Query.hello")
  async resolveHello(): Promise<string> {
    return `Hello, resolved world! Running in environment: ${this.config.environment}`;
  }
}

See the demo package for a complete example, including HTTP routes.

Development

We use the Node test runner, so make sure to install Node.JS v18.13 / v19.2 or higher.

To publish new versions, run pnpm version <new-version> in the appropriate package directory; a new Git tag will be pushed, and the CI will publish the package automatically (see statuses here).