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

@accelbyte/codegen

v4.1.2

Published

AccelByte Code Generator is a CLI tool that facilitates creating an AccelByte TypeScript SDK from AccelByte OpenAPI definitions.

Downloads

888

Readme

AccelByte TypeScript SDK Code Generator

AccelByte Code Generator is a CLI tool that facilitates creating an AccelByte TypeScript SDK from AccelByte OpenAPI definitions.

CLI

This codegen build a CLI called accelbyte-codegen that will be used to generate code from given config.

Commands:  
accelbyte-codegen download-swaggers  Download swaggers JSON files  
accelbyte-codegen generate-code      Generate code based on downloaded swagger files

Options:
--version           Show version number                                                               [boolean]  
--config            Path to the config file with backend service URLs.                                [string] [required]  
--swaggersOutput    Directory to save the downloaded Swagger JSON files.                              [string] [required]  
--output            Directory for the generated code. Required when using the generate-code command.  [string]  
--help              Show help                                                                         [boolean]
--skipReactQuery    Disable React Query code generation.                                              [boolean]
--snippetOutput     Generate only code snippets.                                                      [boolean]
--snippetOnly       Directory for the generated code snippets. Required when generating snippets.     [boolean]
--webSocketSchema   Path to the WebSocket schema file (schema.json).                                  [string]

Config file

Provide swaggers url you wish to generate, store it in .json format file.

[
  ["iam", "Iam", "iam.json", "https://example.com/iam/apidocs/api.json"]
]

How to Generate

Step 1: Set Up Your Node.js Environment Make sure you have Node.js and npm (Node Package Manager) installed on your system. You can download and install them from the official website: https://nodejs.org/en/

*It is recommended to use nvm or fnm to install Node.js so you can switch between Node versions more easily

Step 2: Create a New Node.js Project (if needed) If you are starting a new project, create a new directory and initialize it as a Node.js project. You can do this using the following commands:

mkdir my-project
cd my-project
npm init

Follow the prompts to set up your project's package.json file.

Step 3: Install the Package To use @accelbyte/codegen, you need to install it as a dependency for your project. Run the following command within your project directory:

npm install @accelbyte/codegen
# Or, with yarn:
yarn add @accelbyte/codegen

Step 4: Configure the Package Check the documentation or the README of the package for specific configuration instructions.

  1. Prepare The CHANGELOG.md file, create the Changelog file in the root project with CHANGELOG.md file name.
  2. Prepare Config file, Provide the swaggers URL you wish to generate with the format of an Array of array detailed services, so we can add multiple services at the same time, by adding an Array of detailed services into Config.json Array like this:
[
  [serviceName, aliasName, swaggerFileOutput, swaggerURL],
  [serviceName2, aliasName2, swaggerFileOutput2, swaggerURL2],
  ...
]

and then store it in .json format file (we suggest placing the file in the root directory). example:

[
  ["iam", "Iam", "iam.json", "https://example.com/iam/apidocs/api.json"]
]

for the Accelbyte Demo environment, this will look like this

[
  ["iam", "Iam", "iam.json", "https://demo.accelbyte.io/iam/apidocs/api.json"]
]

Step 5: Download Swagger Files download the swagger file to the project by executing this command

npm exec -- accelbyte-codegen download-swaggers --config ./config.json --swaggersOutput ./swaggers
# Or, with yarn:
yarn accelbyte-codegen download-swaggers --config ./config.json --swaggersOutput ./swaggers

*note: please adjust the --config flag with the path of config.json file that was already set up before, and please specify the swagger output directory by using --swaggersOutput flag.

Step 6: Generate Code from Swagger Files after the swagger file has already been downloaded we can proceed to generating TypeScript SDK code from the Swagger File using this command :

npm exec -- accelbyte-codegen generate-code --config ./config.json --swaggersOutput ./swaggers --output ./sdk

*note: please adjust the --config flag with the path of config.json file that was already set up before, and please specify for the swagger output directory by using --swaggersOutput flag, and the directory output of generated SDK using --output flag. if it is successful the result will look like this, and the WebSDK code should be generated under the/sdk directory

----------
Generating API: { title: 'justice-iam-service', version: '7.4.0' }
!!!! Missing x-version ...
COMPLETED
----------

Step 7: Prettify the files (Optional)

To prettify the code file using the prettier tool, please install the plugin first by doing this:

npm install prettier 
# Or, with yarn:
yarn add prettier

after installing, execute prettier as below

npm exec prettier --write swaggers/*.json && prettier --write sdk/**/*
# Or, with yarn:
yarn prettier --write swaggers/*.json && prettier --write sdk/**/*