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

postcard

v1.1.0

Published

A database driven application platform using PostgreSQL

Downloads

6

Readme

Postcard

A database driven application platform leveraging Electron and PostgreSQL.

What is Postcard

Postcard is a tool for developers that makes writing and distributing database driven applications easy!

Postcard makes it easy to build database apps. Programs for business, like accounting or inventory. Once you've written your application, Postcard helps you package your app for Linux, Mac and Windows computers. When users go to open your app, Postcard will manage starting PostgeSQL.

In order to accomplish all this magic, Postcard makes several interesting choices to bring together an application stack. But although a lot of work went into Postcard, it would not have been possible without the following projects:

Electron

Electron (by Github) is an application shell that provides you with several important components. The first is the web engine from Chromium, which renders your HTML and Javascript just like a browser. In order to display your HTML and Javascript files you need a webserver, so Electron provides and embeds a Node server. Finally, Electron helps you package your application so that you can easily distribute it to Linux, Mac and Windows computers. Electron is a powerful combination of technologies and effort.

PostgreSQL

PostgreSQL is an enterprise class, open source object-relational database. Postcard brings portable binaries of PostgreSQL for Linux, Mac and Windows into Node modules.

Postcard is still pre-release. Please ignore it for now.

Getting Started

There are two functions in Postcard:

postcard.init(appName, callback)

  • appName
  • Postcard uses this to create a folder to hold the PostgreSQL cluster
  • callback(postgresPort)
  • This function will be called after envelope has started up, the postgresPort argument will allow you to tell connect to postgres

postcard.quit()

  • You need to call this function when the process is going to exit. If you don't then PostgreSQL will keep running and you won't be able to start it the next time.

Example

index.js

const postcard = require('postcard');
const electron = require('electron');
const path = require('path');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

let mainWindows = [];

app.on('ready', function () {
	postcard.init('postcard-example', function (postgresPort) {
		var curWindow = new BrowserWindow({
			'width': 1024,
			'height': 768
		});
		mainWindows.push(curWindow);

		curWindow.loadURL('file://' + path.normalize(app.getAppPath() + '/web_root/index.html'), {
			'extraHeaders': 'pragma: no-cache\n'
		});

		// Emitted when the window is closed.
		curWindow.on('closed', function() {
			mainWindows.splice(mainWindows.indexOf(curWindow), 1);
		});
	});
});

app.on('quit', function() {
	postcard.quit();
});

Then in web_root/index.html, to connect to PostgreSQL, you would do something like:

const pg = require('pg');
var client = new pg.Client({
	user: 'main_user',
	database: 'postgres',
	password: 'password',
	host: (process.platform == 'win32' ? '127.0.0.1' : '/tmp'),
	port: fs.readFileSync(path.normalize(os.homedir() + '/.postcard-example/postgres_port')).toString(),
	ssl: false
});