---
# System prepended metadata

title: Concept

---

# Concept

- API
	- index.js
	- entities
		- index.js
```
GET api.rake.ai/v3/entities -> api-server -> GET headers: { x-api-version: v3 } admin.rake.ai/entities
```

File: entities/index.js
```
module.exports = [
	{
		versions: [v3,v2],
		handler: (req,res) => {}
	},
	{
		isDefault: true,
		versions: [v4],
		handler: (req,res) => {}
	}
]
```
File: index.js
```
const entitiesHandler = require('./entities');

const defaultEntitiesHandler = entitiesHandler.find(e => e.isDefault);

router.get('/entities', (req,res) => {
	const version = req.headers[x-api-version];
	if ([null, ''].includes(version)) {
		return defaultEntitiesHandler(req,res);
	}
	
	const handler = entitiesHandler.find(e => e.versions.includes(version));
	if (!handler) {
		return res.status(400).send({ message: 'This version not supported/exists' )
	}
	
	return handler(req,res);
});
```
