Skip to content

Hand-picked API examples for your favorite technology including Go, Node.js, Python and more

License

Notifications You must be signed in to change notification settings

normal-dev/stdlibs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stdlibs.com

Hand-picked API examples for your favorite technology including Go, Node.js, Python and more.

stdlibs.com employs static code analysis to identify and extract real-world examples of standard library usage from curated open-source repositories.

Developing

Prerequisities

The following dependencies are required:

  • Docker
  • MongoDB
  • Go

Depending on what you would like to work on, these dependencies are optional:

  • Node.js (and npm)
  • Python (and pip)

If you would like to work on any contribution, a GitHub personal access token is required, which needs to passed as GITHUB_ACCESS_TOKEN_CONTRIBS flag. This is necessary to clone repositories.

The easiest way to get started is to use the debugging configurations for Visual Studio Code, which can be found inside .vscode/launch.json. If you don't use Visual Studio Code, consult the following sections.

Web

Web contains the frontend (or client) and the API server. Make sure the MongoDB deamon is running at mongodb://localhost:27017 (or provide an URI with the MONGO_DB_URI flag) and serve the client first with:

cd app/web
npm install
npm run serve

Now start the server with:

cd app
go run . --no-client

You should now be able open the browser and see some user interface at http://localhost:5173. Note: It's expected to receive the following error at this point:

invalid argument to Int63n

That's because they are no contributions in your database. To add them, follow the next section.

Contributions

Every technology (Go, Node.js, etc.) has a Dockerfile named Dockerfile.contribs. These are used to build production container. While it's possible to use them for development as well, the recommended way is to use local compiler. Each contribution is written into the MongoDB database.

The following sections explain how to build contributions for each technology.

Go

cd go/contribs
GITHUB_ACCESS_TOKEN_CONTRIBS=YOUR_PERSONAL_ACCESS_TOKEN go run .

Node.js

cd node/mongo
npm install
cd ../contribs
GITHUB_ACCESS_TOKEN_CONTRIBS=YOUR_PERSONAL_ACCESS_TOKEN node index.mjs

Python

cd python/contribs
pip install -r requirements.txt --break-system-packages
GITHUB_ACCESS_TOKEN_CONTRIBS=YOUR_PERSONAL_ACCESS_TOKEN python3 __main__.py

APIs

Similar to contributions, each API has it's own Dockerfile named Dockerfile.apis. Every API is written into the MongoDB database.

The following sections explain how to build APIs for each technology.

Go

cd go/apis
go run .

Node.js

cd node/apis
npm install
npm start

Python

You might need to install Tkinter first (assuming you are using Linux):

sudo apt install python3-tk -y

Now you should be able to run:

cd python/apis
pip install -r requirements.txt --break-system-packages
python3 __main__.py

Production

stdlibs.com is running on production using Google Cloud Run instances. The web app is a service and each contribution and API is a manually invoked job. seo/repos is build via buildpacks.

Glossary

See glossary.