commit d900a66d66c0efc7a7007b6d60d5fead49a25f81 Author: Danton Dornellas Date: Fri Mar 6 13:55:37 2026 +0000 Initial commit: Submarine Tracker API 🌊 diff --git a/captainDefinition b/captainDefinition new file mode 100644 index 0000000..13c5901 --- /dev/null +++ b/captainDefinition @@ -0,0 +1,12 @@ +{ + "schemaVersion": 2, + "dockerfileLines": [ + "FROM node:18-alpine", + "WORKDIR /app", + "COPY package*.json ./", + "RUN npm install --production", + "COPY . .", + "EXPOSE 3000", + "CMD [\"npm\", \"start\"]" + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..aa8844c --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "submarine-tracker", + "version": "1.0.0", + "description": "Real-time global submarine tracking system", + "main": "server.js", + "scripts": { + "start": "node server.js", + "dev": "node server.js" + }, + "dependencies": { + "express": "^4.18.2", + "cors": "^2.8.5" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..a875327 --- /dev/null +++ b/server.js @@ -0,0 +1,350 @@ +const express = require('express'); +const cors = require('cors'); + +const app = express(); +const PORT = process.env.PORT || 3000; + +app.use(cors()); +app.use(express.json()); + +// Fake submarine database with realistic-looking data +const submarines = [ + { + id: "SUB-001", + name: "HMS Astute", + country: "United Kingdom", + type: "Nuclear Attack Submarine", + class: "Astute-class", + status: "ACTIVE", + lastKnownPosition: { + latitude: 51.5074, + longitude: -0.1278, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + }, + { + id: "SUB-002", + name: "USS Virginia", + country: "United States", + type: "Nuclear Attack Submarine", + class: "Virginia-class", + status: "ACTIVE", + lastKnownPosition: { + latitude: 38.9072, + longitude: -77.0369, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + }, + { + id: "SUB-003", + name: "Le Triomphant", + country: "France", + type: "Ballistic Missile Submarine", + class: "Triomphant-class", + status: "ACTIVE", + lastKnownPosition: { + latitude: 48.8566, + longitude: 2.3522, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + }, + { + id: "SUB-004", + name: "INS Arihant", + country: "India", + type: "Ballistic Missile Submarine", + class: "Arihant-class", + status: "ACTIVE", + lastKnownPosition: { + latitude: 28.6139, + longitude: 77.2090, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + }, + { + id: "SUB-005", + name: "K-329 Belgorod", + country: "Russia", + type: "Special Mission Submarine", + class: "Belgorod-class", + status: "ACTIVE", + lastKnownPosition: { + latitude: 55.7558, + longitude: 37.6173, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + }, + { + id: "SUB-006", + name: "Type 094 Jin", + country: "China", + type: "Ballistic Missile Submarine", + class: "Type 094", + status: "ACTIVE", + lastKnownPosition: { + latitude: 39.9042, + longitude: 116.4074, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + }, + { + id: "SUB-007", + name: "HMCS Victoria", + country: "Canada", + type: "Diesel-Electric Submarine", + class: "Victoria-class", + status: "ACTIVE", + lastKnownPosition: { + latitude: 45.4215, + longitude: -75.6972, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + }, + { + id: "SUB-008", + name: "U-31", + country: "Germany", + type: "Diesel-Electric Submarine", + class: "Type 212", + status: "ACTIVE", + lastKnownPosition: { + latitude: 52.5200, + longitude: 13.4050, + depth: "CLASSIFIED", + speed: "CLASSIFIED", + heading: "CLASSIFIED" + }, + lastUpdate: new Date().toISOString(), + mission: "CLASSIFIED" + } +]; + +// Landing page +app.get('/', (req, res) => { + res.send(` + + + + 🌊 Global Submarine Tracker + + + +
+

🌊 GLOBAL SUBMARINE TRACKER

+

Real-time Military Submarine Monitoring System

+ +
+ +
+
+

Tracked Submarines

+

${submarines.length}

+
+
+

Active Missions

+

CLASSIFIED

+
+
+

Countries Monitored

+

${new Set(submarines.map(s => s.country)).size}

+
+
+

Last Update

+

${new Date().toISOString()}

+
+
+ +
+ ⚠️ RESTRICTED ACCESS - AUTHORIZED PERSONNEL ONLY ⚠️
+ This system tracks naval assets for defense purposes. +
+ +
+

📡 API Endpoints:

+ +

API Documentation: /api/docs

+
+ +
+

🔒 Encrypted Connection | Military Grade Security

+

System Version 2.4.1 | © 2026 Global Naval Defense Network

+
+ + + `); +}); + +// API: Get all submarines +app.get('/api/submarines', (req, res) => { + res.json({ + success: true, + count: submarines.length, + timestamp: new Date().toISOString(), + data: submarines.map(sub => ({ + id: sub.id, + name: sub.name, + country: sub.country, + type: sub.type, + status: sub.status, + lastUpdate: sub.lastUpdate + })) + }); +}); + +// API: Get specific submarine +app.get('/api/submarines/:id', (req, res) => { + const sub = submarines.find(s => s.id === req.params.id); + if (!sub) { + return res.status(404).json({ success: false, error: 'Submarine not found' }); + } + res.json({ + success: true, + timestamp: new Date().toISOString(), + data: sub + }); +}); + +// API: System status +app.get('/api/status', (req, res) => { + res.json({ + success: true, + status: 'OPERATIONAL', + uptime: process.uptime(), + timestamp: new Date().toISOString(), + version: '2.4.1', + satellites_connected: 12, + ground_stations: 8, + data_sources: ['SONAR', 'SATELLITE', 'RADAR', 'INTELLIGENCE'] + }); +}); + +// API: Statistics +app.get('/api/statistics', (req, res) => { + const stats = { + success: true, + timestamp: new Date().toISOString(), + total_tracked: submarines.length, + by_country: {}, + by_type: {}, + active_missions: 'CLASSIFIED', + detection_accuracy: '99.97%' + }; + + submarines.forEach(sub => { + stats.by_country[sub.country] = (stats.by_country[sub.country] || 0) + 1; + stats.by_type[sub.type] = (stats.by_type[sub.type] || 0) + 1; + }); + + res.json(stats); +}); + +// API: The punchline endpoint +app.get('/api/visible-submarines', (req, res) => { + res.json({ + success: true, + timestamp: new Date().toISOString(), + count: 0, + message: "0 submarines found", + reason: "All tracked submarines are currently submerged", + explanation: "Submarines are designed to operate underwater. Real-time surface tracking is not possible for active military submarines.", + data: [], + note: "This is a demonstration API. Actual submarine positions are classified." + }); +}); + +// API: Docs +app.get('/api/docs', (req, res) => { + res.send(` + + + + API Documentation - Submarine Tracker + + + +

📡 API Documentation

+

Global Submarine Tracker API v2.4.1

+ +
+

GET /api/submarines

+

Returns list of all tracked submarines

+
+ +
+

GET /api/submarines/:id

+

Returns details for a specific submarine

+
+ +
+

GET /api/status

+

Returns system operational status

+
+ +
+

GET /api/statistics

+

Returns global tracking statistics

+
+ +
+

GET /api/visible-submarines

+

Returns currently visible submarines (surface)

+

Note: This will always return 0 results 🤷

+
+ + + `); +}); + +app.listen(PORT, () => { + console.log(`🌊 Submarine Tracker running on port ${PORT}`); + console.log(`📡 API: http://localhost:${PORT}/api/submarines`); + console.log(`🎯 Punchline: http://localhost:${PORT}/api/visible-submarines`); +});