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

roxterjs

v0.1.8

Published

O RoxterJS Router é um framework para gerenciar requisições de diferentes verbos HTTPs e possui um mecanismo de rotas baseado no conceito de pastas e subpastas aninhadas.

Downloads

35

Readme

Generic badge Generic badge

Status da api

  • [x] Estável em produção
  • [x] Ultima versão 2024-04-02
  • [x] Versão atualizada v0.1.8

Novidades

# .env.test
$ ROXTER_MODE = "dev"|"prod" #default -> dev. Obrigatório mudar p/ "prod" em ambiente de produção.
$ ROXTER_PORT = 3333 #default -> porta de entrada (não obrigatório)
$ ROXTER_HOSTNAME = "localhost" #default (não obrigatório)
$ ROXTER_FILE_PATH = "./" #default -> __root pasta onde o arquivo app.routes.js será criado (não obrigatório)
$ ROXTER_FILE_ROUTES = "app.routes.js" #default -> nome_do_arquivo onde as rotas serão salvas (não obrigatório)
$ ROXTER_TIMEOUT = 10000 #default -> tempo limite de espera para resposta do serviço (não obrigatório)
$ ROXTER_CPUS = 0 #default -> detalhes no texto abaixo...

ROXTER_CPUS

Primeiros passos (exemplo):

# Crie um novo package.json
$ npm init -y
# npm ou yarn
$ npm i roxterjs
# app.js
  • root_projeto
    • app.js
    • package.json
    • README.md
    • src/
      • routes/
      • controller/
      • services/
# app.js
import Roxter from "roxterjs";
const roxter = await Roxter('./src/routes'); # <-caminho-> './src/routes'

# A função abaixo irá construir as rotas e iniciar o servidor
roxter.Start();

Criando uma rota:

  • root_projeto
    • app.js
    • package.json
    • README.md
    • src/
      • routes/
        • api/
          • view/
# http://localhost:3333/api/view
  • root_projeto
    • app.js
    • package.json
    • README.md
    • src/
      • routes/
        • api/
          • view/
            • get.js
# http://localhost:3333/api/view
# __root/src/routes/api/view/get.js

export default async function App({ res }){
    return res.end(JSON.stringfy({
        name: "RoxterJs",
        partner: "Roxter.Xteezer",
        address: "São Paulo - SP"
    }))
}
# Teste cURL:
$ curl -X GET http://localhost:3333/api/view

Recebendo uma [parâmetros]

# __root/src/routes/api/view/[id]/get.js

export default async function App({ res, keys }){
    const { id } = await keys;
    return res.end(`Sua chave é ${id}`);
}
# Teste cURL:
$ curl -X GET http://localhost:3333/api/view/1234

Recebendo [querys]

# __root/src/routes/api/view/[id]/get.js

export default async function App({ res, keys, params }){
    const { color } = await params;
    const { id } = await keys;
    return res.end(`Sua chave é ${id}, sua cor é ${color}`);
}
# Teste cURL:
$ curl -X GET http://localhost:3333/api/view/1234?color=azul

Recebendo um [body]

  • root_projeto
    • app.js
    • package.json
    • README.md
    • src/
      • routes/
        • api/
          • view/
            • ...
        • data/
          • dong/
            • post.js
# http://localhost:3333/data/dong
# __root/src/routes/data/dong/post.js

export default async function App({ res, body }){
    const { id } = await body;
    return res.end(`Sua chave é ${id}`);
}
# Teste cURL:
$ curl -X POST http://localhost:3333/data/dong -d '{"id":"191919"}'

Adicionando Resposta ao Header (setHeader)

# app.js
import Roxter from "roxterjs";
const roxter = await Roxter('./src/routes'); 

# Adicione como parâmetro Start({ params })
roxter.Start({
    setHeaders:[
        { name: "Access-Control-Allow-Origin", value: "*" },
        { name: "Access-Control-Allow-Methods", value: "GET, OPTIONS, POST, PUT" },
        { name: "Access-Control-Allow-Headers", value: "Access-Control-Allow-Headers, Origin, X-Requested-With, Content-Type, Accept, Authorization" }
    ]
});

🎲 Github

# Clone este repositório
$ git clone https://github.com/packrd/roxterjs.git

🛠 Tecnologias

As seguintes ferramentas foram usadas na construção do projeto:

Colaboradores

:1st_place_medal: @rodrigo.buttura