mirror of https://github.com/iconify/api.git
Rename project to Iconify API
This commit is contained in:
parent
6b0c18dba8
commit
4334756ac8
2
app.js
2
app.js
|
|
@ -322,7 +322,7 @@ app.get('/robots.txt', (req, res) => {
|
|||
|
||||
// Debug information and AWS health check
|
||||
app.get('/version', (req, res) => {
|
||||
let body = 'SimpleSVG CDN version ' + version + ' (Node';
|
||||
let body = 'Iconify API version ' + version + ' (Node';
|
||||
if (config.region.length) {
|
||||
body += ', ' + config.region;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"reload-secret": "",
|
||||
"custom-icons-dir": "{dir}/json",
|
||||
"serve-default-icons": true,
|
||||
"index-page": "https://simplesvg.com/",
|
||||
"index-page": "https://iconify.design/",
|
||||
"cache": {
|
||||
"timeout": 604800,
|
||||
"min-refresh": 604800,
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
"storage": "{dir}/git-repos",
|
||||
"git": "git clone {repo} --depth 1 --no-tags {target}",
|
||||
"secret": "",
|
||||
"simple-svg": "git@github.com:simplesvg/icons.git",
|
||||
"iconify": "git@github.com:iconify-design/collections-json.git",
|
||||
"custom": "",
|
||||
"custom-dir": "",
|
||||
"rm": "rm -rf {dir}"
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
"repeat": 180,
|
||||
"from": "noreply@localhost",
|
||||
"to": "noreply@localhost",
|
||||
"subject": "SimpleSVG icons log",
|
||||
"subject": "Iconify API log",
|
||||
"transport": {
|
||||
"host": "smtp.ethereal.email",
|
||||
"port": 587,
|
||||
|
|
|
|||
16
config.md
16
config.md
|
|
@ -40,7 +40,7 @@ Use {dir} variable to specify application's directory.
|
|||
|
||||
#### serve-default-icons
|
||||
|
||||
True if default SimpleSVG icons set should be served.
|
||||
True if default Iconify icons set should be served.
|
||||
|
||||
#### index-page
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ Set to true if page cache should be treated as private.
|
|||
|
||||
## Reloading icon sets
|
||||
|
||||
SimpleSVG icons server has ability to reload collections without restarting server. That allows to run server uninterrupted during icon sets updates.
|
||||
Iconify API has ability to reload collections without restarting server. That allows to run server uninterrupted during icon sets updates.
|
||||
|
||||
|
||||
#### reload-secret
|
||||
|
|
@ -87,11 +87,11 @@ Server will respond identically with "ok" message regardless of reload status to
|
|||
|
||||
In addition to reloading all collections without restarting server, server can pull collections from Git service and reload collections without restarting. This can be used to push collections to server whenever its updated without downtime.
|
||||
|
||||
There are two collections available: simple-svg and custom.
|
||||
There are two collections available: iconify and custom.
|
||||
|
||||
All configuration options are in "sync" object in config-default.json. Use {dir} variable in directories to point to application directory.
|
||||
|
||||
To synchronize repository send GET request to /sync?repo=simple-svg&key=your-sync-key
|
||||
To synchronize repository send GET request to /sync?repo=iconify&key=your-sync-key
|
||||
Replace repo with "custom" to synchronize custom repository and key with value of sync.secret
|
||||
|
||||
Server will respond identically with "ok" message regardless of status to prevent visitors from trying to guess your secret key.
|
||||
|
|
@ -134,9 +134,9 @@ Location of directory where repositories will be stored.
|
|||
|
||||
Git command. You can change it if you need to customize command that is executed to clone repository. {repo} will be replaced with repository URL, {target} will be replaced with target directory.
|
||||
|
||||
#### simple-svg
|
||||
#### iconify
|
||||
|
||||
URL of SimpleSVG icons repository.
|
||||
URL of Iconify icons repository.
|
||||
|
||||
#### custom
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ URL of custom icons repository.
|
|||
|
||||
Location of json files in custom repository, relative to root directory of repository.
|
||||
|
||||
For example, if json files are located in directory "json" in your repository (like they are in simple-svg repository), set custom-dir value to "json".
|
||||
For example, if json files are located in directory "json" in your repository (like they are in iconify repository), set custom-dir value to "json".
|
||||
|
||||
|
||||
## Logging errors
|
||||
|
|
@ -181,7 +181,7 @@ Received email address. Set this to valid email address.
|
|||
|
||||
Subject of emails. All emails will have same subject.
|
||||
|
||||
If you are running SimpleSVG icons app on multiple servers, use different subjects for different servers to identify which server email came from.
|
||||
If you are running Iconify API on multiple servers, use different subjects for different servers to identify which server email came from.
|
||||
|
||||
#### transport
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Vjacheslav Trushkin
|
||||
Copyright (c) 2017, 2018 Vjacheslav Trushkin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
{
|
||||
"name": "simple-svg-website-icons",
|
||||
"version": "1.0.0-beta7",
|
||||
"version": "1.0.0-beta8",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@iconify/json": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/json/-/json-1.0.0.tgz",
|
||||
"integrity": "sha512-SKp4GPm4jFd9faAsNG8XL+LUgUMabvJJoT7UURPCq+c1/T46fL0nErHtTRd7qzhYljKj5LTzh9ztB7TzkH1IHw=="
|
||||
},
|
||||
"accepts": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
|
||||
|
|
@ -325,7 +329,7 @@
|
|||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
|
||||
},
|
||||
"merge-descriptors": {
|
||||
|
|
@ -344,16 +348,16 @@
|
|||
"integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ=="
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.36.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz",
|
||||
"integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw=="
|
||||
"version": "1.37.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz",
|
||||
"integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.20",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz",
|
||||
"integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==",
|
||||
"version": "2.1.21",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz",
|
||||
"integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==",
|
||||
"requires": {
|
||||
"mime-db": "~1.36.0"
|
||||
"mime-db": "~1.37.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
|
|
@ -540,18 +544,6 @@
|
|||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz",
|
||||
"integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ=="
|
||||
},
|
||||
"simple-svg-icons": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-svg-icons/-/simple-svg-icons-2.0.0.tgz",
|
||||
"integrity": "sha512-Zf9eGWIV+V8tV3OLowJJ3xPDT2DyuA+AToYKJyUz3pLSaJie8ak/aq5WvU4d1IPzZQJOn0dwe3LGHs5ZDsAoZA==",
|
||||
"requires": {
|
||||
"simple-svg-icons-data": "git+https://github.com/simplesvg/icons.git#b4c059b3aefd5c54983d04e665a62bceb0446e1b"
|
||||
}
|
||||
},
|
||||
"simple-svg-icons-data": {
|
||||
"version": "git+https://github.com/simplesvg/icons.git#b4c059b3aefd5c54983d04e665a62bceb0446e1b",
|
||||
"from": "git+https://github.com/simplesvg/icons.git"
|
||||
},
|
||||
"statuses": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
|
||||
|
|
|
|||
14
package.json
14
package.json
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "simple-svg-website-icons",
|
||||
"version": "1.0.0-beta7",
|
||||
"description": "Node.js version of icons.simplesvg.com",
|
||||
"version": "1.0.0-beta8",
|
||||
"description": "Node.js version of api.iconify.design",
|
||||
"private": true,
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
|
|
@ -9,10 +9,16 @@
|
|||
},
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify-design/api.js/issues",
|
||||
"homepage": "https://github.com/iconify-design/api.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/iconify-design/api.js.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.16.4",
|
||||
"nodemailer": "^4.6.8",
|
||||
"simple-svg-icons": "^2.0.0"
|
||||
"@iconify/json": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# SimpleSVG icons website
|
||||
# Iconify.design API
|
||||
|
||||
This code runs on icons.simplesvg.com that is used to serve collections and SVG images.
|
||||
This code runs on api.iconify.design that is used to serve collections and SVG images.
|
||||
|
||||
PHP version is available at https://github.com/simplesvg/website-icons.php
|
||||
PHP version is available at https://github.com/iconify-design/api.php
|
||||
|
||||
|
||||
### How to use it
|
||||
|
|
|
|||
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const fs = require('fs');
|
||||
|
|
|
|||
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const fs = require('fs');
|
||||
|
|
@ -66,12 +75,12 @@ class Collections {
|
|||
}
|
||||
|
||||
switch (repo) {
|
||||
case 'simple-svg':
|
||||
case 'iconify':
|
||||
// Get collections.json
|
||||
let filename = dirs.rootDir(repo) + '/collections.json';
|
||||
fs.readFile(filename, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
reject('Error locating collections.json for SimpleSVG default icons.');
|
||||
reject('Error locating collections.json for Iconify default icons.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
17
src/dirs.js
17
src/dirs.js
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
let config, _dirs;
|
||||
|
|
@ -23,7 +32,7 @@ const functions = {
|
|||
let dir;
|
||||
|
||||
switch (repo) {
|
||||
case 'simple-svg':
|
||||
case 'iconify':
|
||||
dir = functions.rootDir(repo);
|
||||
return dir === '' ? '' : dir + '/json';
|
||||
|
||||
|
|
@ -75,9 +84,9 @@ module.exports = appConfig => {
|
|||
|
||||
// Set default directories
|
||||
if (config['serve-default-icons']) {
|
||||
let icons = require('simple-svg-icons');
|
||||
repos.push('simple-svg');
|
||||
_dirs['simple-svg'] = icons.rootDir();
|
||||
let icons = require('@iconify/json');
|
||||
repos.push('iconify');
|
||||
_dirs['iconify'] = icons.rootDir();
|
||||
}
|
||||
|
||||
if (config['custom-icons-dir']) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const nodemailer = require('nodemailer');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Alternative to Promise.all() that runs each promise after another, not simultaneously
|
||||
*
|
||||
* @param list
|
||||
* @param callback
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
module.exports = (list, callback) => new Promise((fulfill, reject) => {
|
||||
let results = [];
|
||||
|
||||
|
|
|
|||
11
src/query.js
11
src/query.js
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const generateSVG = require('./svg');
|
||||
|
|
@ -58,7 +67,7 @@ module.exports = (collection, query, ext, params) => {
|
|||
return 400;
|
||||
}
|
||||
} else {
|
||||
callback = 'SimpleSVG._loaderCallback';
|
||||
callback = 'Iconify._loaderCallback';
|
||||
}
|
||||
return {
|
||||
type: 'application/javascript; charset=utf-8',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* This file is part of the simple-svg-cdn package.
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* This file is part of the simple-svg-cdn package.
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
|
|
@ -47,7 +47,7 @@ module.exports = body => {
|
|||
return body;
|
||||
}
|
||||
|
||||
prefix = 'SimpleSVGId-' + Date.now().toString(16) + '-' + (Math.random() * 0x1000000 | 0).toString(16) + '-';
|
||||
prefix = 'IconifyId-' + Date.now().toString(16) + '-' + (Math.random() * 0x1000000 | 0).toString(16) + '-';
|
||||
|
||||
// Replace with unique ids
|
||||
ids.forEach(function(id) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const replaceIDs = require('./svg-ids');
|
||||
|
|
|
|||
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* This file is part of the @iconify/api package.
|
||||
*
|
||||
* (c) Vjacheslav Trushkin <cyberalien@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const fs = require('fs'),
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
icons: 'alias1'
|
||||
})).to.be.eql({
|
||||
type: 'application/javascript; charset=utf-8',
|
||||
body: 'SimpleSVG._loaderCallback({"prefix":"test","icons":{"icon2":{"body":"<icon2 />","width":24,"height":24}},"aliases":{"alias1":{"parent":"icon2","hFlip":true}}})'
|
||||
body: 'Iconify._loaderCallback({"prefix":"test","icons":{"icon2":{"body":"<icon2 />","width":24,"height":24}},"aliases":{"alias1":{"parent":"icon2","hFlip":true}}})'
|
||||
});
|
||||
|
||||
// Query collection without prefix, json
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
let result = parseQuery(collection2, 'icon3', 'svg', {
|
||||
color: 'red',
|
||||
rotate: '90deg'
|
||||
}).body.replace(/SimpleSVGId-[0-9a-f]+-[0-9a-f]+-[0-9]+/g, 'some-id');
|
||||
}).body.replace(/IconifyId-[0-9a-f]+-[0-9a-f]+-[0-9]+/g, 'some-id');
|
||||
|
||||
expect(result).to.be.equal('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g transform="rotate(90 12 12)"><defs><foo id="some-id" /></defs><bar use="url(#some-id)" fill="red" stroke="red" /></g></svg>');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue