How to use bookbrainz-data - 10 common examples

To help you get started, we’ve selected a few bookbrainz-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bookbrainz / bookbrainz-site / test / bookbrainz-data.js View on Github external
*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

import BookBrainzData from 'bookbrainz-data';
import config from '../config/test.json';


const orm = BookBrainzData(config.database);

// opens up database connection for later use in tests
export default orm;
github bookbrainz / bookbrainz-site / src / api / app.js View on Github external
import config from '../common/helpers/config';
import express from 'express';
import initRoutes from './routes';
import logger from 'morgan';
import redis from 'connect-redis';
import session from 'express-session';


Promise.config({
	longStackTraces: true,
	warnings: true
});

// Initialize application
const app = express();
app.locals.orm = BookBrainzData(config.database);


app.set('trust proxy', config.site.proxyTrust);

if (app.get('env') !== 'testing') {
	app.use(logger('dev'));
}

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
	extended: false
}));
app.use(compression());


const RedisStore = redis(session);
github bookbrainz / bookbrainz-site / src / server / app.js View on Github external
import logger from 'morgan';
import path from 'path';
import redis from 'connect-redis';
import routes from './routes';
import serveStatic from 'serve-static';
import session from 'express-session';


Promise.config({
	longStackTraces: true,
	warnings: true
});

// Initialize application
const app = express();
app.locals.orm = BookBrainzData(config.database);

const rootDir = path.join(__dirname, '../../');

app.set('trust proxy', config.site.proxyTrust);

app.use(favicon(path.join(rootDir, 'static/images/icons/favicon.ico')));

if (app.get('env') !== 'testing') {
	app.use(logger('dev'));
}

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
	extended: false
}));
app.use(compression());
github bookbrainz / bookbrainz-site / src / server / routes / entity / edition.js View on Github external
* GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

'use strict';

const express = require('express');
const router = express.Router();
const auth = require('../../helpers/auth');

const utils = require('../../helpers/utils');

const Edition = require('bookbrainz-data').Edition;
const EditionHeader = require('bookbrainz-data').EditionHeader;
const EditionRevision = require('bookbrainz-data').EditionRevision;
const Publication = require('bookbrainz-data').Publication;
const Publisher = require('bookbrainz-data').Publisher;

const React = require('react');
const ReactDOMServer = require('react-dom/server');
const EditForm = React.createFactory(
	require('../../../client/components/forms/edition.jsx')
);

/* Middleware loader functions. */
const makeEntityLoader = require('../../helpers/middleware').makeEntityLoader;

const loadEditionStatuses =
	require('../../helpers/middleware').loadEditionStatuses;
github bookbrainz / bookbrainz-site / src / server / routes / entity / edition.js View on Github external
* with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

'use strict';

const express = require('express');
const router = express.Router();
const auth = require('../../helpers/auth');

const utils = require('../../helpers/utils');

const Edition = require('bookbrainz-data').Edition;
const EditionHeader = require('bookbrainz-data').EditionHeader;
const EditionRevision = require('bookbrainz-data').EditionRevision;
const Publication = require('bookbrainz-data').Publication;
const Publisher = require('bookbrainz-data').Publisher;

const React = require('react');
const ReactDOMServer = require('react-dom/server');
const EditForm = React.createFactory(
	require('../../../client/components/forms/edition.jsx')
);

/* Middleware loader functions. */
const makeEntityLoader = require('../../helpers/middleware').makeEntityLoader;

const loadEditionStatuses =
	require('../../helpers/middleware').loadEditionStatuses;
const loadEditionFormats =
	require('../../helpers/middleware').loadEditionFormats;
const loadLanguages =
github bookbrainz / bookbrainz-site / src / server / routes / entity / edition.js View on Github external
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

'use strict';

const express = require('express');
const router = express.Router();
const auth = require('../../helpers/auth');

const utils = require('../../helpers/utils');

const Edition = require('bookbrainz-data').Edition;
const EditionHeader = require('bookbrainz-data').EditionHeader;
const EditionRevision = require('bookbrainz-data').EditionRevision;
const Publication = require('bookbrainz-data').Publication;
const Publisher = require('bookbrainz-data').Publisher;

const React = require('react');
const ReactDOMServer = require('react-dom/server');
const EditForm = React.createFactory(
	require('../../../client/components/forms/edition.jsx')
);

/* Middleware loader functions. */
const makeEntityLoader = require('../../helpers/middleware').makeEntityLoader;

const loadEditionStatuses =
	require('../../helpers/middleware').loadEditionStatuses;
const loadEditionFormats =
	require('../../helpers/middleware').loadEditionFormats;
const loadLanguages =
	require('../../helpers/middleware').loadLanguages;
github bookbrainz / bookbrainz-site / src / server / routes / entity / work.js View on Github external
* GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

'use strict';

const express = require('express');
const router = express.Router();
const auth = require('../../helpers/auth');

const utils = require('../../helpers/utils');

const Work = require('bookbrainz-data').Work;
const WorkHeader = require('bookbrainz-data').WorkHeader;
const WorkRevision = require('bookbrainz-data').WorkRevision;
const bookshelf = require('bookbrainz-data').bookshelf;

/* Middleware loader functions. */
const makeEntityLoader = require('../../helpers/middleware').makeEntityLoader;

const React = require('react');
const ReactDOMServer = require('react-dom/server');
const EditForm =
	React.createFactory(require('../../../client/components/forms/work.jsx'));

const loadLanguages = require('../../helpers/middleware').loadLanguages;
const loadWorkTypes = require('../../helpers/middleware').loadWorkTypes;
const loadEntityRelationships =
	require('../../helpers/middleware').loadEntityRelationships;
github bookbrainz / bookbrainz-site / src / server / routes / entity / work.js View on Github external
* with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

'use strict';

const express = require('express');
const router = express.Router();
const auth = require('../../helpers/auth');

const utils = require('../../helpers/utils');

const Work = require('bookbrainz-data').Work;
const WorkHeader = require('bookbrainz-data').WorkHeader;
const WorkRevision = require('bookbrainz-data').WorkRevision;
const bookshelf = require('bookbrainz-data').bookshelf;

/* Middleware loader functions. */
const makeEntityLoader = require('../../helpers/middleware').makeEntityLoader;

const React = require('react');
const ReactDOMServer = require('react-dom/server');
const EditForm =
	React.createFactory(require('../../../client/components/forms/work.jsx'));

const loadLanguages = require('../../helpers/middleware').loadLanguages;
const loadWorkTypes = require('../../helpers/middleware').loadWorkTypes;
const loadEntityRelationships =
	require('../../helpers/middleware').loadEntityRelationships;
const loadIdentifierTypes =
	require('../../helpers/middleware').loadIdentifierTypes;
github bookbrainz / bookbrainz-site / src / server / routes / achievement.js View on Github external
router.get('/admin', (req, res) => {
	const EditorJSONPromise = new Editor()
		.orderBy('name')
		.fetchAll()
		.then((editors) => {
			return editors.map((editor) => {
				const editorJSON = editor.toJSON();
				return {
					id: editorJSON.id,
					name: editorJSON.name
				}
			});
		});

	const AchievementJSONPromise = new AchievementType()
		.orderBy('name')
		.fetchAll()
		.then((achievements) => {
			const achievementList = achievements.toJSON();
			achievementList.unshift({id: 'none', name: 'No Achievement'});
			console.log(achievementList);
			return achievementList;
		});

	const TitleJSONPromise = new TitleType()
		.orderBy('title')
		.fetchAll()
		.then((titles) => {
			const titleList = titles.toJSON();
			titleList.unshift({id: 'none', title: 'No Title'});
			return titleList;
github bookbrainz / bookbrainz-site / src / server / routes / achievement.js View on Github external
name: editorJSON.name
				}
			});
		});

	const AchievementJSONPromise = new AchievementType()
		.orderBy('name')
		.fetchAll()
		.then((achievements) => {
			const achievementList = achievements.toJSON();
			achievementList.unshift({id: 'none', name: 'No Achievement'});
			console.log(achievementList);
			return achievementList;
		});

	const TitleJSONPromise = new TitleType()
		.orderBy('title')
		.fetchAll()
		.then((titles) => {
			const titleList = titles.toJSON();
			titleList.unshift({id: 'none', title: 'No Title'});
			return titleList;
		});

	Promise.join(EditorJSONPromise,
		AchievementJSONPromise,
		TitleJSONPromise,
		(editorJSON, achievementJSON, titleJSON) => {
			const props = {
				editor: editorJSON,
				achievement: achievementJSON,
				title: titleJSON