<commit_before>'use strict';

const apiResult = require('../modules/api-result');
const dbConnector = require('../modules/db-connector')();
const getMissingParams = require('../modules/get-missing-params');
const type = require('../modules/type');

exports.post = (request, extensions) => new Promise((resolve, reject) => (async () => {
	const userId = request.user._id;
	const name = request.body.name;
	const description = request.body.description;
	const permissions = request.body.permissions;

	const db = await dbConnector.connectApidbAsync();

	if (await db.findArrayAsync('applications', {name: name}).length >= 1)
		return reject(apiResult(400, 'already exists name'));

	// TODO: analyze permissions

	let application;

	try {
		application = await db.createAsync('applications', {
			name: name,
			creator_id: userId,
			description: description,
			permissions: permissions
		});<commit_msg>remove disuse require<commit_after>'use strict';

const apiResult = require('../modules/api-result');
const dbConnector = require('../modules/db-connector')();
const type = require('../modules/type');

exports.post = (request, extensions) => new Promise((resolve, reject) => (async () => {
	const userId = request.user._id;
	const name = request.body.name;
	const description = request.body.description;
	const permissions = request.body.permissions;

	const db = await dbConnector.connectApidbAsync();

	if (await db.findArrayAsync('applications', {name: name}).length >= 1)
		return reject(apiResult(400, 'already exists name'));

	// TODO: analyze permissions

	let application;

	try {
		application = await db.createAsync('applications', {
			name: name,
			creator_id: userId,
			description: description,
			permissions: permissions
		});
{'fraction_non_alphanumeric': 0.14865637507146942, 'fraction_numerical': 0.004574042309891366, 'mean_word_length': 4.813953488372093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5256384', 'n_tokens_mistral': 531, 'n_tokens_neox': 500, 'n_words': 129}