This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async getMyIp(req: Request, res: Response) { | |
const ip = | |
req.headers["cf-connecting-ip"] || | |
req.headers["x-real-ip"] || | |
req.headers["x-forwarded-for"] || | |
req.socket.remoteAddress || ""; | |
return res.status(200).send({ip}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface ICountry { | |
name: string; | |
code: string; | |
} | |
export const Countries: ICountry[] = [ | |
{name: "Afghanistan", code: "AF"}, | |
{name: "Åland Islands", code: "AX"}, | |
{name: "Albania", code: "AL"}, | |
{name: "Algeria", code: "DZ"}, | |
{name: "American Samoa", code: "AS"}, |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
- Follow standard conventions.
- Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
- Boy scout rule. Leave the campground cleaner than you found it.
- Always find root cause. Always look for the root cause of a problem.