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

@mapeo/map-server

v1.0.0-alpha.13

Published

Serve raster & vector map tiles along with style resources for GL maps

Downloads

26

Readme

Mapeo Map Server

Build Status

An in-progress offline map style and tile server for Mapeo.

npm install @mapeo/map-server better-sqlite3

⚠️ This is alpha software. No guarantees can be made about the stability of the API at the moment, so proceed with caution. 😄

Features

  • [x] Manages tiles and tilesets (TileJSON)

  • [x] Manages Mapbox map styles

  • [x] Supports importing MBTile files as tilesets

    • [x] Supports getting import progress
  • [ ] Provides info related to downloads and storage

Usage

The default export is a factory function for creating a map server instance, which is built on top of Fastify. Basic usage is as follows:

// better-sqlite3 is a peer dependency and must be installed manually.
const Database = require('better-sqlite3')
// If you're using TypeScript, you may want to use one of the following import syntaxes to get type definitions:
// - `require('@mapeo/map-server').default`
// - `import createMapServer from '@mapeo/map-server'
const createMapServer = require('@mapeo/map-server')

// Create the server instance
const mapServer = createMapServer(
  { logger: true },
  { data: new Database('./example.db') }
)

// Run the server!
mapServer.listen(3000, function (err) {
  if (err) {
    mapServer.log.error(err)
    process.exit(1)
  }
})

createServer(fastifyOpts, mapServerOpts): FastifyInstance

Creates the map server instance

  • fastifyOpts (optional): Options object to customize the Fastify instance. Refer to the official Fastify documentation for more details.
  • mapServerOpts (required): Options object to customize the map server instance. Options include:
    • database: BetterSqlite3.Database (required): BetterSqlite3 database instance representing the SQLite database to use.

API Documentation

API documentation is available in the API.md and by accessing the /docs endpoint of the server when it's running.

Technical Details

  • Fastify for creating the server.
  • SQLite as the underlying persistence layer.
  • Prisma as a build tool for updating the schema, creating migration scripts, and generating schema assets.
    • Schema diagram can be found here.
    • Due to the distributed and local-first nature of Mapeo, migrations are performed at runtime by the server on initialization. See the migrations implementation for more details. It roughly follows the logic that Prisma uses for build-time migrations.

Developing

Some notes before working on this locally:

  • If you make any changes to the schema via schema.prisma, run the following commands afterwards:
    • npm run prisma:migrate-dev -- --name MIGRATION_NAME_HERE - creates a new migration in the prisma/migrations/ directory, which is used by tests and the server if running locally

License

MIT