Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
APP_URL=http://localhost
BASE_URL=http://127.0.0.1
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_NAME=sentinel
DATABASE_USER=sentinel
DATABASE_PASSWORD=sentinel
REDIS_HOST=localhost
REDIS_PORT=6379
JOB_UI_PORT=6574
TRACK_ENABLED=true
TRACK_NPC=false
TRACK_FLEETS=true
FLEET_EXPIRY_IN_MINUTES=30
CACHE_CHARACTERS_IN_DAYS=7
BACKFILL_ENABLED=true
BACKFILL_ENABLED=false
BACKFILL_OFFSET=0
BACKFILL_SCHEDULE=0 11 * * *
TIMEZONE=Atlantic/Reykjavik
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ lib-cov
*.pid

.env
.github

# EVE SDE
evedb/
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

A WebSocket-compatible kill & fleet tracker for EVE Online, built [on Sails.js](https://sailsjs.com/). Part of the magic behind the [GLOSS](https://github.com/dougestey/gloss) project.

## Features ##
## Features

- Backed by PostgreSQL
- Live reporting from zKillboard's [WebSocket service](https://github.com/zKillboard/zKillboard/wiki/Websocket)
- Identifies fleet patterns based on recorded kills
- Resolves characters, corporations and alliances via [ESI](https://esi.tech.ccp.is/)
- Resolves shiptypes and systems via the [EVE Online SDE](https://developers.eveonline.com/resource/resources)
- Sophisticated job queue scheduling via [Kue](https://github.com/Automattic/kue)

## Environment ##
## Environment

- Install Node >= 8
- Install Yarn
- Install and [configure](config/datastores.js) a database (PostgreSQL preferred)
- Install and [configure](config/datastores.js) a database (PostgreSQL preferred)
- Install and [configure](config/jobs.js) Redis

The app will refuse to run without a valid root-level `.env` - see the [example file.](.env.example)

## Boot ##
## Boot

$ cd sentinel
$ yarn
Expand All @@ -31,7 +32,7 @@ Provided it's not firewalled, a frontend to the job queue will be available at `

If you're going to leave this thing running permanently, you should run it with `NODE_ENV=production` (i.e. `npm start`).

## Support ##
## Support

Got a problem? File a GitHub issue. Please be nice.

Expand Down
96 changes: 46 additions & 50 deletions api/controllers/CharacterController.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
/**
* CharacterController
*
* @description :: Character lookup controller
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/

module.exports = {

async find(req, res) {
let { name } = req.query;

if (name) {
characters = await Character.find({
where: {
name: {
contains: name
}
}
});
} else {
characters = await Character.find(req.query);
}

let results = [];

for (let character of characters) {
let result = await CharacterSerializer.one(character.id);

results.push(result);
}

return res.status(200).json(results);
},

async findOne(req, res) {
if (!req.params.id)
return res.badRequest();

let { id } = req.params;

let character = await CharacterSerializer.one(id);

if (!character)
return res.notFound();

return res.status(200).json(character);
}

};
/**
* CharacterController
*
* @description :: Character lookup controller
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/

module.exports = {
async find(req, res) {
let { name } = req.query;

if (name) {
characters = await Character.find({
where: {
name: {
contains: name,
},
},
});
} else {
characters = await Character.find(req.query);
}

let results = [];

for (let character of characters) {
let result = await CharacterSerializer.one(character.id);

results.push(result);
}

return res.status(200).json(results);
},

async findOne(req, res) {
if (!req.params.id) return res.badRequest();

let { id } = req.params;

let character = await CharacterSerializer.one(id);

if (!character) return res.notFound();

return res.status(200).json(character);
},
};
12 changes: 4 additions & 8 deletions api/controllers/FleetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@
*/

module.exports = {

async findOne(req, res) {
if (!req.params.id)
return res.badRequest();
if (!req.params.id) return res.badRequest();

let { id } = req.params;

let fleet = await FleetSerializer.one(id);

if (!fleet)
return res.notFound();
if (!fleet) return res.notFound();

return res.status(200).json(fleet);
},

async active (req, res) {
async active(req, res) {
let fleets = await Fleet.find({ isActive: true });
let resolved = [];

Expand All @@ -32,6 +29,5 @@ module.exports = {
}

return res.status(200).json(resolved);
}

},
};
6 changes: 2 additions & 4 deletions api/controllers/SocketController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

module.exports = {

connect(req, res) {
if (req.isSocket) {
Dispatcher.joinPool(req);
Expand All @@ -15,6 +14,5 @@ module.exports = {
}

return res.status(403).send();
}

}
},
};
12 changes: 5 additions & 7 deletions api/controllers/StatusController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module.exports = {

async status(req, res) {
return res.status(200).json(sails.config.sentinel);
}

}
module.exports = {
async status(req, res) {
return res.status(200).json(sails.config.sentinel);
},
};
13 changes: 2 additions & 11 deletions api/models/Alliance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
*/

module.exports = {

attributes: {

id: { type: 'number', autoIncrement: false, required: true },

name: 'string',

ticker: 'string',

activeCombatPilots: 'number',

hasSupers: 'boolean',

dangerRatio: 'number'

}

dangerRatio: 'number',
},
};
16 changes: 2 additions & 14 deletions api/models/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,19 @@
*/

module.exports = {

attributes: {

id: { type: 'number', autoIncrement: false, required: true },

name: 'string',

dangerRatio: 'number',

// Relationships

corporation: { model: 'corporation' },

alliance: { model: 'alliance' },

fleet: { model: 'fleet' },

history: { collection: 'fleet', via: 'history' },

// Meta

lastEsiUpdate: 'string',

lastZkillUpdate: 'string'

}

lastZkillUpdate: 'string',
},
};
55 changes: 23 additions & 32 deletions api/models/Constellation.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
/**
* Constellation.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/documentation/concepts/models-and-orm/models
*/

let datastore = 'sdeDev';

if (process.env.NODE_ENV === 'production') {
datastore = 'sde';
}

module.exports = {

datastore,

tableName: 'mapConstellations',

attributes: {

createdAt: false,

updatedAt: false,

id: { columnName: 'constellationID', type: 'number', autoIncrement: false, required: true },

name: { columnName: 'constellationName', type: 'string' },

}

};
/**
* Constellation.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/documentation/concepts/models-and-orm/models
*/

module.exports = {
datastore: 'sde', // this model references the EVE SDE
tableName: 'mapConstellations',

attributes: {
createdAt: false,
updatedAt: false,
id: {
columnName: 'constellationID',
type: 'number',
autoIncrement: false,
required: true,
},
name: { columnName: 'constellationName', type: 'string' },
},
};
14 changes: 2 additions & 12 deletions api/models/Corporation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,13 @@
*/

module.exports = {

attributes: {

id: { type: 'number', autoIncrement: false, required: true },

name: 'string',

ticker: 'string',

memberCount: 'number',

activeCombatPilots: 'number',

hasSupers: 'boolean',

dangerRatio: 'number'

}

dangerRatio: 'number',
},
};
Loading