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

@mgrdevport/simple-strapi-types

v0.0.6

Published

Simple typescript interface generator for Strapi 4 models

Downloads

56

Readme

simple-strapi-types

This is a stripped down version of @oak-digital/types-4-strapi-2

types-4-strapi-2 is a rewrite of francescolorenzetti/types-4-strapi written in TypeScript, with the goal of being much easier to extend and maintain.

Requirements

  • Node >=v16

Getting started

Install the script for your project:

# NPM
npm install --save-dev @mgrdevport/simple-strapi-types
# YARN
yarn add -D @mgrdevport/simple-strapi-types

Then set up a script in your package.json

// package.json
{
    "scripts": {
        "types": "st4s"
    }
}

In some cases it is desirable to change the output directory which is ./types by default. This can be done with the --out flag like in the following example.

// package.json
{
    "scripts": {
        "types": "st4s --out ../frontend/src/lib/types"
    }
}

Features

  • Generate TypeScript interfaces for all your api content-types and components
  • Generate TypeScript interfaces for builtin types such as Media and MediaFormat
  • Select input and output directory
  • Prettier formatting and ability to use your own .prettierrc.
  • Generate types for plugins such as url-alias
  • Population by generics

Planned features

  • Support for localization

Flags

| Flag | Description | Default | |-----------------------------|--------------------------------------------------------------------------------------|-------------| | -i, --in | The src directory for strapi | ./src | | -o, --out | The output directory to output the types to | ./types | | --prefix | A prefix for all generated interfaces | I | | --component-prefix | A prefix for components | none | | -D, --delete-old | CAUTION: This option is equivalent to running rm -rf on the output directory first | false | | --prettier | The prettier config file to use for formatting TypeScript interfaces | none | | --plugins <plugins...> | The plugins to use | none |

Using plugins

It is possible to generate types for plugins, for example url-alias gives a new field on your content types, so that plugin will automatically add that field to your types. You can see a list of builtin plugins below. Some plugins might not be fully featured.

It will be possible in the future to add your own plugins in later versions.

List of supported plugins

  • url-alias

example of using plugins

$ st4s --plugins url-alias

Population

This stripped down version doesn't deal with population, just use the interfaces as they fall out of the generator.

Building

To build this project, use the following command

npm run build

Publishing

npm version # major | minor | patch
npm run build
npm publish